From 7eaf95de9b86965efa385669551712ffbce82522 Mon Sep 17 00:00:00 2001 From: thinkphp Date: Wed, 9 Nov 2016 13:53:36 +0800 Subject: [PATCH] =?UTF-8?q?=E8=AF=B7=E6=B1=82=E7=BC=93=E5=AD=98=E7=9A=84?= =?UTF-8?q?=E6=9C=89=E6=95=88=E6=9C=9F=E5=A6=82=E6=9E=9C=E4=BC=A0=E5=85=A5?= =?UTF-8?q?false=E8=A1=A8=E7=A4=BA=E4=B8=8D=E7=BC=93=E5=AD=98=20=E8=B7=AF?= =?UTF-8?q?=E7=94=B1=E8=A7=84=E5=88=99=E7=9A=84cache=E5=8F=82=E6=95=B0?= =?UTF-8?q?=E4=BC=A0=E5=85=A5false=E4=B9=9F=E5=90=8C=E6=A0=B7=E8=A1=A8?= =?UTF-8?q?=E7=A4=BA=E4=B8=8D=E7=BC=93=E5=AD=98=20=E5=8D=B3=E4=BD=BF?= =?UTF-8?q?=E5=BC=80=E5=90=AF=E4=BA=86=E5=85=A8=E5=B1=80=E8=AF=B7=E6=B1=82?= =?UTF-8?q?=E7=BC=93=E5=AD=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- library/think/Request.php | 9 ++++++--- library/think/Route.php | 2 +- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/library/think/Request.php b/library/think/Request.php index 8a354633..45b65423 100644 --- a/library/think/Request.php +++ b/library/think/Request.php @@ -1486,6 +1486,12 @@ class Request public function cache($key, $expire = null) { if (false !== $key && $this->isGet() && !$this->isCheckCache) { + // 标记请求缓存检查 + $this->isCheckCache = true; + if (false === $expire) { + // 关闭当前缓存 + return; + } if ($key instanceof \Closure) { $key = call_user_func_array($key, [$this]); } elseif (true === $key) { @@ -1518,9 +1524,6 @@ class Request $key = $fun($key); } - // 标记请求缓存检查 - $this->isCheckCache = true; - if (strtotime($this->server('HTTP_IF_MODIFIED_SINCE')) + $expire > $_SERVER['REQUEST_TIME']) { // 读取缓存 $response = Response::create()->code(304); diff --git a/library/think/Route.php b/library/think/Route.php index 63cbe9c4..c8eb24e6 100644 --- a/library/think/Route.php +++ b/library/think/Route.php @@ -1491,7 +1491,7 @@ class Route $result = self::parseModule($route); } // 开启请求缓存 - if ($request->isGet() && !empty($option['cache'])) { + if ($request->isGet() && isset($option['cache'])) { $cache = $option['cache']; if (is_array($cache)) { list($key, $expire) = $cache;