-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
51 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,59 @@ | ||
# laravel-middleware-response-cache | ||
# Laravel中间件-Response缓存 | ||
|
||
Laravel中间件-Response缓存(进行中...ing...) | ||
## 功能 | ||
|
||
- 支持缓存渲染后数据 | ||
- 支持指定缓存过期时间(默认10分钟) | ||
- header头输出缓存命中状态、缓存Key及过期时间 | ||
|
||
## 安装 | ||
|
||
```sh | ||
composer require flc/laravel-middleware-cache-response | ||
``` | ||
|
||
> 进行中-不稳定版本 | ||
## 配置 | ||
|
||
> `\app\Http\Kernel.php`文件中`$routeMiddleware`增加: | ||
```php | ||
<?php | ||
'cache.response' => \Flc\Laravel\Http\Middleware\CacheResponse::class, | ||
|
||
// cache.response 命名随意,你开心就好 | ||
``` | ||
|
||
## 使用 | ||
|
||
```php | ||
<?php | ||
Route::get('/', function () { | ||
return view('welcome'); | ||
})->middleware('cache.response'); | ||
|
||
Route::get('/', function () { | ||
return view('welcome'); | ||
})->middleware('cache.response:20'); // 指定缓存时间20分钟 | ||
``` | ||
|
||
## 附录 | ||
|
||
**缓存规则** | ||
|
||
- 当前URL全路径md5 | ||
|
||
**Headers** | ||
|
||
``` | ||
X-Cache:Missed | ||
X-Cache-Expires:2018-03-29 15:08:29 CST | ||
X-Cache-Key:6c9b19774e2c304a42d200f314d8c80b | ||
``` | ||
|
||
## TODO | ||
|
||
- 增加`status`、`header`的支持 | ||
|
||
## Licenes | ||
|
||
MIT |