1
如何在Yii中啓用頁面緩存?我跟着文檔,但它不工作。
http://www.yiiframework.com/doc-2.0/guide-caching-page.html
http://www.yiiframework.com/doc-2.0/guide-structure-filters.html#pagecache如何在Yii中啓用頁面緩存?它不起作用
class SiteController extends Controller {
public function behaviors() {
return [
'pageCache' => [
'class' => 'yii\filters\PageCache',
'only' => ['index'],
'duration' => 10*60,
'variations' => [
\Yii::$app->language,
],
Server response
HTTP/1.1 200 OK
Date: Thu, 02 Apr 2015 01:25:06 GMT
Server: Apache/2.2.29 (Unix) mod_ssl/2.2.29 OpenSSL/1.0.2a DAV/2 PHP/5.6.7
X-Powered-By: PHP/5.6.7
Set-Cookie: ...cookies...
Vary: Accept-Encoding
Content-Encoding: gzip
Content-Length: 4750
Keep-Alive: timeout=5, max=100
Connection: Keep-Alive
Content-Type: text/html; charset=UTF-8
公告不存在Cache-Control:max-age=
或Expires:
標題。如果我將該類更改爲xPageCache
,那麼它會因錯誤而失敗,因此它正在讀取設置。
你可以擴展對我們「不工作」嗎?你怎麼知道它不工作?你在響應頭文件中尋找什麼? – halfer 2015-04-02 01:38:22
@halfer更新。 – Chloe 2015-04-02 02:02:32
是否值得暫時取出'only'來查看問題是否存在? – halfer 2015-04-02 02:17:15