kudashevs/laravel-last-modified
Composer 安装命令:
composer require kudashevs/laravel-last-modified
包简介
A Laravel middleware that handles the If-Modified-Since request and Last-Modified response headers.
README 文档
README
This Laravel package contains a handler for the If-Modified-Since request and Last-Modified response headers.
Installation
You can install the package via composer:
composer require kudashevs/laravel-last-modified
Then, register the middleware in the app/Http/Kernel.php:
protected $middleware = [ 'web' => [ ... \Kudashevs\LaravelLastModified\Middleware\LastModified::class, ], ];
You may also want to publish the configuration file (optional).
php artisan vendor:publish --provider="Kudashevs\LaravelLastModified\Providers\LastModifiedServiceProvider"
After deploying your application, check whether the headers are handled correctly.
How it works
First, the middleware identifies the last modification time of a given url by parsing the request. It tries to retrieve this information from possible origins in the following order (if it cannot retrieve the information, it moves forward):
- a first model in the view data,
- a first collection in the view data,
- a first paginator in the view data,
- a compiled view file,
- a view file,
- as a last resort, a fallback.
After the last modification time has been retrieved, the middleware sets the Last-Modified response header. Then,
it handles the If-Modified-Since request header using the last modification time from the previous step.
Configuration
After publishing, the configuration settings are located in the config/last-modified.php file.
There configuration options are currently supported:
'enable' # A boolean defines whether the middleware is enabled (default `true`).
'aggressive' # A boolean defines whether the middleware returns a response immediately (default is `false`).
'fallback' # An integer the fallback timestamp for the Last-Modifier header.
'origins' # An array with a list of origins of the last modification time.
'exclude' # An array with a list of paths to be excluded from processing.
, for more information please see the configuration file.
Testing
composer test
References
Contributing
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
Note: Please make sure to update tests as appropriate.
License
The MIT License (MIT). Please see the License file for more information.
kudashevs/laravel-last-modified 适用场景与选型建议
kudashevs/laravel-last-modified 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 875 次下载、GitHub Stars 达 0, 最近一次更新时间为 2025 年 01 月 11 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「laravel」 「if-modified-since」 「http headers」 「Last-Modified」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 kudashevs/laravel-last-modified 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 kudashevs/laravel-last-modified 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 kudashevs/laravel-last-modified 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Cache and conditional request helpers for PSR-7 HTTP Messages
repository php library
Setting the Last-Modified header and 304 Not Modified response code if the page hasn't changed since the last visit
Cache and conditional request helpers for PSR-7 HTTP Messages
http客户端
Easily add Excepct-CT header to your project
统计信息
- 总下载量: 875
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 10
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-01-11