doufan1363 2015-04-02 01:33
浏览 177

如何在Yii中启用页面缓存? 它不起作用

How do I enable page caching in Yii? I followed the documentation, but it's not working.
http://www.yiiframework.com/doc-2.0/guide-caching-page.html
http://www.yiiframework.com/doc-2.0/guide-structure-filters.html#pagecache

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

Notice there is no Cache-Control:max-age= or Expires: heading. If I change the class to xPageCache then it does fail with an error, so it's reading the settings.

  • 写回答

1条回答 默认 最新

  • drkwpgrdb092239314 2015-04-07 03:55
    关注

    It was working. I had to update the design of the page and it would not show the changes after reload. It seems to be a server side rendering cache, not a HTTP browser cache. So it saves rendering the page, but not the request/response to the server.

    评论

报告相同问题?

悬赏问题

  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 对于相关问题的求解与代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作