doufang2023
2014-02-05 09:20
浏览 156
已采纳

Yii禁用http缓存

How can I disable the http cache on Yii? The browser can't update the view, until I refresh the browser manually.

Is there some like cakephp disableCache()?

图片转代码服务由CSDN问答提供 功能建议

如何在Yii上禁用http缓存? 在我手动刷新浏览器之前,浏览器无法更新视图。

有没有像cakephp disableCache()?

  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

2条回答 默认 最新

  • dqqg0811 2014-02-05 09:40
    已采纳

    CakePHP's function does

    $this->header(array(
        'Expires' => 'Mon, 26 Jul 1997 05:00:00 GMT',
        'Last-Modified' => gmdate("D, d M Y H:i:s") . " GMT",
        'Cache-Control' => 'no-store, no-cache, must-revalidate, post-check=0, pre-check=0'
    ));
    

    so maybe you can make a function with:

    header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
    header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
    header("Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0");
    

    and call it when needed.

    已采纳该答案
    打赏 评论
  • douqiaotong8682 2014-02-05 09:40

    Check your filters() method inside your controller and/or base controller (if you're using it). There should be something like 'CHttpCacheFilter' in it, just remove that. By default HttpCache isn't enabled.

    More details: http://www.yiiframework.com/doc/guide/1.1/nl/caching.page#http-caching

    If you don't use the CHttpCacheFilter, check your .htaccess file, perhaps there is some http caching done as well.

    打赏 评论

相关推荐 更多相似问题