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