swisnl/laravel-static-request-cache
最新稳定版本:1.5.0
Composer 安装命令:
composer require swisnl/laravel-static-request-cache
包简介
Cache static responses based on content-type to static files.
README 文档
README
🚨 THIS PACKAGE HAS BEEN ABANDONED 🚨
We don't use this package anymore in our own projects — we switched to Nginx with FastCGI Caching — and cannot justify the time needed to maintain it anymore. That's why we have chosen to abandon it. Feel free to fork our code and maintain your own copy or use one of the many alternatives. We suggest using silber/page-cache instead as it is fairly similar.
Install
Via Composer
$ composer require swisnl/laravel-static-request-cache
Setup
Add the middleware to the end of your Http/Kernel.php middleware array.
protected $middleware = [ \Swis\Laravel\StaticRequestCache\Http\Middleware\CacheMiddleware::class, ];
Add the following snippet into your .htaccess
# Rewrite to html cache if it exists and the request is for a static page
# (no url query params and only get requests)
RewriteCond %{REQUEST_METHOD} GET
RewriteCond %{QUERY_STRING} !.*=.*
RewriteCond %{DOCUMENT_ROOT}/static/html%{REQUEST_URI} -f
RewriteRule ^(.*)$ /static/html%{REQUEST_URI} [L]
RewriteCond %{REQUEST_METHOD} GET
RewriteCond %{QUERY_STRING} !.*=.*
RewriteCond %{REQUEST_URI} !index.php
RewriteCond %{DOCUMENT_ROOT}/static/html%{REQUEST_URI}/index.html -f
RewriteRule ^(.*)$ /static/html%{REQUEST_URI}/index.html [L]
Disabling
If you want to disable the cache for some reason (the content might be dynamic), you can use the StaticRequestCache singleton in the IoC:
public function __construct(StaticRequestCache $staticRequestCache) { $this->staticRequestCache = $staticRequestCache; $this->staticRequestCache->disable(); }
Or use the Facade:
StaticRequestCache::disable();
Please note that this package also checks for Cache-control headers and caches accordingly. You can change this behaviour in the config by editing non_cacheable_cache_control_values.
Clear the files
To clear all the files manually you can use an artisan command.
$ php artisan static-html-cache:clear
Change log
Please see CHANGELOG for more information on what has changed recently.
Testing
$ composer test
Contributing
Please see CONTRIBUTING and CODE_OF_CONDUCT for details.
Security
If you discover any security related issues, please email security@swis.nl instead of using the issue tracker.
Credits
Based on mscharl/laravel-static-html-cache. Added configuration for setting cacheable content-type and non-cacheable cache control values.
License
The MIT License (MIT). Please see License File for more information.
This package is Treeware. If you use it in production, then we ask that you buy the world a tree to thank us for our work. By contributing to the Treeware forest you’ll be creating employment for local families and restoring wildlife habitats.
SWIS ❤️ Open Source
SWIS is a web agency from Leiden, the Netherlands. We love working with open source software.
swisnl/laravel-static-request-cache 适用场景与选型建议
swisnl/laravel-static-request-cache 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 5.84k 次下载、GitHub Stars 达 3, 最近一次更新时间为 2017 年 11 月 28 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「swisnl」 「laravel-static-request-cache」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 swisnl/laravel-static-request-cache 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 swisnl/laravel-static-request-cache 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 swisnl/laravel-static-request-cache 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Fixture handler for Guzzle 6+
Model Context Protocol client implementation in PHP
PHP server integration for AG-UI - standardized AI agent frontend communication via Server-Sent Events
NDW Melvin API client
Laravel lti provider
Integrates spatie/laravel-activitylog with Filament
统计信息
- 总下载量: 5.84k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 3
- 点击次数: 32
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2017-11-28