如何避免 codeigniter 缓存

How to avoid codeigniter cache

我们在 codeingiter 框架中开发了一个网站。我们在 codeigniter 缓存问题中遇到了问题。像这样的问题

当用户登录时,我们的 header 栏信息应该是欢迎 Mr.xxxxx。 如果用户已注销,我们的 header 信息应该是 Welcome Guest。

此处用户注销后,header显示注销用户名。

同时按 Ctrl+F5。它会正确显示。

我们尝试了很多。

同时设置数据库查询缓存为 false $db['default']['cache_on'] = FALSE;

缓存文件夹(application\cache)内除了index.html和.htaccess

外没有缓存文件

输出缓存也是$this->output->cache(0);

也试过这个。

<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"/>

任何帮助或指向正确的方向都可以。谢谢!

您是否尝试过使用 CI 的输出 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');