PHP code example of anerg2046 / laravel-cache-page

1. Go to this page and download the library: Download anerg2046/laravel-cache-page library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

anerg2046 / laravel-cache-page example snippets


'cache.response' => \anerg\Laravel\Http\Middleware\CacheResponse::class,
// cache.response 命名随意,你开心就好

return [
    //是否不进行缓存 - 开发模式下,应该为true
    'skip'       => false,
    //是否允许url参数 跳过缓存
    'allowSkip'  => true,
    //是否允许url参数 清空缓存
    'allowFlush' => true,
    //是否允许url参数 清除当前地址缓存
    'allowClear' => true
];


Route::get('/', function () {
    return view('welcome');
})->middleware('cache.response');

Route::get('/', function () {
    return view('welcome');
})->middleware('cache.response:20');  // 指定缓存时间20分钟