@@ -8,7 +8,7 @@ discard block |
||
| 8 | 8 | // +---------------------------------------------------------------------- |
| 9 | 9 | // | Author: liu21st <[email protected]> |
| 10 | 10 | // +---------------------------------------------------------------------- |
| 11 | -declare (strict_types = 1); |
|
| 11 | +declare(strict_types=1); |
|
| 12 | 12 | |
| 13 | 13 | namespace think\middleware; |
| 14 | 14 | |
@@ -88,9 +88,9 @@ discard block |
||
| 88 | 88 | |
| 89 | 89 | if (isset($key) && 200 == $response->getCode() && $response->isAllowCache()) { |
| 90 | 90 | $header = $response->getHeader(); |
| 91 | - $header['Cache-Control'] = 'max-age=' . $expire . ',must-revalidate'; |
|
| 92 | - $header['Last-Modified'] = gmdate('D, d M Y H:i:s') . ' GMT'; |
|
| 93 | - $header['Expires'] = gmdate('D, d M Y H:i:s', time() + $expire) . ' GMT'; |
|
| 91 | + $header['Cache-Control'] = 'max-age='.$expire.',must-revalidate'; |
|
| 92 | + $header['Last-Modified'] = gmdate('D, d M Y H:i:s').' GMT'; |
|
| 93 | + $header['Expires'] = gmdate('D, d M Y H:i:s', time() + $expire).' GMT'; |
|
| 94 | 94 | |
| 95 | 95 | $this->cache->tag($tag)->set($key, [$response->getContent(), $header, time()], $expire); |
| 96 | 96 | } |
@@ -141,12 +141,12 @@ discard block |
||
| 141 | 141 | if (false !== strpos($key, ':')) { |
| 142 | 142 | $param = $request->param(); |
| 143 | 143 | foreach ($param as $item => $val) { |
| 144 | - if (is_string($val) && false !== strpos($key, ':' . $item)) { |
|
| 145 | - $key = str_replace(':' . $item, $val, $key); |
|
| 144 | + if (is_string($val) && false !== strpos($key, ':'.$item)) { |
|
| 145 | + $key = str_replace(':'.$item, $val, $key); |
|
| 146 | 146 | } |
| 147 | 147 | } |
| 148 | 148 | } elseif (strpos($key, ']')) { |
| 149 | - if ('[' . $request->ext() . ']' == $key) { |
|
| 149 | + if ('['.$request->ext().']' == $key) { |
|
| 150 | 150 | // 缓存某个后缀的请求 |
| 151 | 151 | $key = md5($request->url()); |
| 152 | 152 | } else { |