mscharl / laravel-static-html-cache
此包已被弃用且不再维护。未建议替代包。
将store/cache生成的响应存储为静态文件
v1.1
2017-08-31 13:22 UTC
Requires
- php: >=7.0
- illuminate/console: ^5.0
- illuminate/filesystem: ^5.0
- illuminate/http: ^5.0
- illuminate/routing: ^5.0
- illuminate/support: ^5.0
This package is not auto-updated.
Last update: 2020-01-16 23:29:03 UTC
README
将store/cache生成的响应存储为静态文件
配置
将服务提供者添加到 config/app.php
的提供者数组中
MScharl\LaravelStaticHtmlCache\Provider\LaravelStaticHtmlCacheProvider::class,
然后将中间件添加到你的 Http/Kernel.php
中间件数组的末尾。
protected $middleware = [ \MScharl\LaravelStaticHtmlCache\Http\Middleware\LaravelStaticHtmlCacheMiddleware::class, ];
将以下片段添加到你的 .htaccess
# Rewrite to html cache if it exists and the request is off a static page
# (no url query params and only get requests)
RewriteCond %{REQUEST_METHOD} GET
RewriteCond %{QUERY_STRING} !.*=.*
RewriteCond %{DOCUMENT_ROOT}/cache/html%{REQUEST_URI}/index.html -f
RewriteRule ^(.*)$ /cache/html%{REQUEST_URI}/index.html [L]
清除文件
要手动清除所有文件,你可以使用 artisan 任务。
php artisan static-html-cache:clear