mscharl / laravel-static-html-cache
store/cache generated responses as a static file
Installs: 5 508
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 1
Open Issues: 0
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 generated responses as a static file
Setup
Add the service provider to the config/app.php
provider array
MScharl\LaravelStaticHtmlCache\Provider\LaravelStaticHtmlCacheProvider::class,
Then add the middleware to the end of your Http/Kernel.php
middleware array.
protected $middleware = [ \MScharl\LaravelStaticHtmlCache\Http\Middleware\LaravelStaticHtmlCacheMiddleware::class, ];
Add the following snippet into your .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]
Clear the files
To clear all the files manually you can use an artisan task.
php artisan static-html-cache:clear