How to avoid codeigniter cache

末鹿安然 提交于 2019-12-25 05:29:30

问题


we developed a site in codeingiter framework. we are facing a issue in codeigniter cache problem. The problem like this

When user is logged in, our header bar info should be Welcome Mr.xxxxx. If user is logged out, our header info should be Welcome Guest.

Here user after logged out, the header is showing logged out user name.

While am pressing Ctrl+F5. It will appear correctly.

We tried a lot.

also set database query cache false $db['default']['cache_on'] = FALSE;

Inside a cache folder(application\cache) there is no cache file except index.html and .htaccess

The output cache also be $this->output->cache(0);.

And Also tried this one.

<meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate"/>
<meta http-equiv="Pragma" content="no-cache"/>
<meta http-equiv="Expires" content="0"/>

Any help or pointing in the right direction will be fine. Thx!


回答1:


Have you tried using CI's output class?

http://www.codeigniter.com/userguide3/libraries/output.html#CI_Output::set_header

$this->output->set_header('HTTP/1.0 200 OK');
$this->output->set_header('HTTP/1.1 200 OK');
$this->output->set_header('Last-Modified: '.gmdate('D, d M Y H:i:s', $last_update).' GMT');
$this->output->set_header('Cache-Control: no-store, no-cache, must-revalidate');
$this->output->set_header('Cache-Control: post-check=0, pre-check=0');
$this->output->set_header('Pragma: no-cache');


来源:https://stackoverflow.com/questions/28476165/how-to-avoid-codeigniter-cache

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!