fts/cache-response is a Laravel package for laravel 5 response cache.
It currently has 1 GitHub stars and 15 downloads on Packagist (latest version v1.0.3).
Install it with composer require fts/cache-response.
Discover more Laravel packages by fts
or browse all Laravel packages to compare alternatives.
Last updated
composer require fts/cache-response
打开 config/app.php 并添加以下内容到 providers 数组:
fts\CacheResponse\CacheResponseServiceProvider.php::class
打开 app/Http/Kernel.php 并添加以下内容到 routeMiddleware 数组:
'page-cache' => fts\CacheResponse\Middleware\CacheResponse::class
对于nginx:
更新location块try_files内容
location = / {
try_files /static/index.html /index.php?$query_string;
}
location / {
try_files $uri $uri/ /static/$uri.html /index.php?$query_string;
}
对于apache:
打开public\.htaccess 添加以下内容
RewriteCond %{REQUEST_URI} ^/?$
RewriteCond %{DOCUMENT_ROOT}/static/index.html -f
RewriteRule .? page-cache/index.html [L]
RewriteCond %{DOCUMENT_ROOT}/static%{REQUEST_URI}.html -f
RewriteRule . static%{REQUEST_URI}.html [L]
Router::middleware('page-cache')->get('');
uri:可选参数,指定要删除缓存的静态文件
php artisan page-cache:clear uri
uri:可选参数,指定要生成缓存的url
php artisan page-cache:create uri
config/pageCache.php
是否自动失效:
isAutoExpired:true | false
有效时间(分钟):
expire:默认30分钟
缓存目录:
cachePath:path