| Conditions | 4 |
| Paths | 4 |
| Total Lines | 18 |
| Code Lines | 9 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 36 | public function handle($request, Closure $next) |
||
| 37 | { |
||
| 38 | $cache = $request->cache(); |
||
| 39 | |||
| 40 | if ($cache) { |
||
| 41 | list($key, $expire, $tag) = $cache; |
||
| 42 | |||
| 43 | if (strtotime($request->server('HTTP_IF_MODIFIED_SINCE')) + $expire > $request->server('REQUEST_TIME')) { |
||
| 44 | // 读取缓存 |
||
| 45 | return Response::create()->code(304); |
||
| 46 | } elseif ($this->cache->has($key)) { |
||
| 47 | list($content, $header) = $this->cache->get($key); |
||
| 48 | |||
| 49 | return Response::create($content)->header($header); |
||
| 50 | } |
||
| 51 | } |
||
| 52 | |||
| 53 | return $next($request); |
||
| 54 | } |
||
| 56 |