laravel-html-cache maintained by domatskiy
Description
laravel HTML Cache
Author
Last update
2020/09/07 17:05
(dev-master)
License
Downloads
2 689
Tags
Laravel HTML Cache
###Install
composer require domatskiy/laravel-html-cache
Publish needed
php artisan vendor:publish --provider="Domatskiy\HtmlCache\HtmlCacheServiceProvider"
Add information about the provider to the config/app.php => providers
Domatskiy\HtmlCache\HtmlCacheServiceProvider::class
to the config/app.php => aliases
'HtmlCache' => Domatskiy\HtmlCache\Facades\HtmlCache::class,
add Middleware to the App\Http\Kernel.php => $routeMiddleware
'html-cache' => \Domatskiy\HtmlCache\Middleware\HTMLCacheMiddleware::class
###Use in routers
Route::middleware(['html-cache'])->group(function (){
# your routes
});
###Commands clearing the html cache
php artisan html-cache:clear
#Usage Register the middleware in the Kernel file: app\Http\Kernel.php
protected $routeMiddleware = [
...
'html-cache' => \Domatskiy\HtmlCache\Middleware\HtmlCacheMiddleware::class,
...
];
Use middleware in the routes
Route::group(['middleware' => ['html-cache']], function () {
Route::get('/', [
'uses' => 'IndexController@index'
]);
});
# To return different pages from the html cache when changing query parameters
# Example: tracking parameters page and section_id
Route::group(['middleware' => ['html-cache:page,section_id']], function () {
Route::get('/lessons', [
'uses' => 'IndexController@index'
]);
});