我如何告诉 Codeigniter 不要存储缓存?
How do I tell Codeigniter not to store cache?
我有一个 Codeigniter 2.2 项目。在不更改代码的情况下,我的浏览器以某种方式为以前登录的用户保留了缓存。如果我重新加载清除缓存然后它显示当前登录的用户。
我添加了My_Output核心控制器。并在注销功能中添加 $this->output->clear_cache()
。我还添加了
<IfModule mod_headers.c>
Header set Cache-Control "no-cache, no-store, must-revalidate"
Header set Pragma "no-cache"
Header set Expires 0
</IfModule>
在我的 .htaccess 文件中。还是一样的问题
您必须向客户发送正确的 headers。
$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");
$this->CI =& get_instance();
$this->CI->session->sess_destroy();
$this->cache->clean();
redirect(base_url());
我有一个 Codeigniter 2.2 项目。在不更改代码的情况下,我的浏览器以某种方式为以前登录的用户保留了缓存。如果我重新加载清除缓存然后它显示当前登录的用户。
我添加了My_Output核心控制器。并在注销功能中添加 $this->output->clear_cache()
。我还添加了
<IfModule mod_headers.c>
Header set Cache-Control "no-cache, no-store, must-revalidate"
Header set Pragma "no-cache"
Header set Expires 0
</IfModule>
在我的 .htaccess 文件中。还是一样的问题
您必须向客户发送正确的 headers。
$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");
$this->CI =& get_instance();
$this->CI->session->sess_destroy();
$this->cache->clean();
redirect(base_url());