当我在注销后按下后退按钮时,PHP Codeigniter正在显示缓存

当我在注销后按下后退按钮时,PHP Codeigniter正在显示缓存,php,codeigniter,session,caching,Php,Codeigniter,Session,Caching,在我从应用程序注销后,当我按下后退按钮时,该用户的所有登录选项仍显示在页面上 登录后,当我按下后退按钮时,它将显示页面的注销版本 我试着在我的注销控制器中设置这个 function logout() { $this->output->set_header('cache-Control: no-store, no-cache, must-revalidate'); $this->output->set_header("cache-Control: post-

在我从应用程序注销后,当我按下后退按钮时,该用户的所有登录选项仍显示在页面上

登录后,当我按下后退按钮时,它将显示页面的注销版本

我试着在我的注销控制器中设置这个

function logout() {
    $this->output->set_header('cache-Control: no-store, no-cache, must-revalidate');
    $this->output->set_header("cache-Control: post-check=0, pre-check=0", false);
    $this->output->set_header("Pragma: no-cache");
    $this->output->set_header("Expires: Sat, 26 Jul 1997 05:00:00 GMT");
    $this->tank_auth->logout();
    redirect(subdomain() . 'home');
}
 public function __construct()
      {
          parent::__construct();

           $this->output->set_header('Last-Modified:'.gmdate('D, d M Y H:i:s').'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',false);
           $this->output->set_header('Pragma: no-cache');
    }
但当我按下后退按钮时,缓存仍然存在。我怎样才能解决这个问题

-----更新------


我认为缓存不是这里的问题,我在开发者设置中禁用了chrome中的缓存,但当我按下后退按钮时,我的浏览器在注销后仍然会进入安全页面


所以缓存不是问题。

读这篇文章,我认为它对你很有用

试试这个

$this->cache->clean();


您好,很抱歉说缓存不是问题所在。缓存是个问题!我通过将此代码放在codeigniter的index.php文件中修复了此问题

header("Expires: Thu, 19 Nov 1981 08:52:00 GMT");
header("Cache-Control: no-store, no-cache, must-revalidate");

只需将其添加到控制器中

function logout() {
    $this->output->set_header('cache-Control: no-store, no-cache, must-revalidate');
    $this->output->set_header("cache-Control: post-check=0, pre-check=0", false);
    $this->output->set_header("Pragma: no-cache");
    $this->output->set_header("Expires: Sat, 26 Jul 1997 05:00:00 GMT");
    $this->tank_auth->logout();
    redirect(subdomain() . 'home');
}
 public function __construct()
      {
          parent::__construct();

           $this->output->set_header('Last-Modified:'.gmdate('D, d M Y H:i:s').'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',false);
           $this->output->set_header('Pragma: no-cache');
    }

我找不到源代码,所以我可能是错的,但是如果我没有记错的话,有一个问题/错误,缓存控制头没有通过输出类正确发送,使用标准的
header()
函数解决了这个问题。这与缓存无关-在大多数浏览器中,后退按钮不会刷新页面,它只是显示了你的历史记录中的页面。您好,我试图在facebook上注销,然后按下后退按钮,它显示了注册facebook的主页面。如果facebook只显示你的历史记录中的页面,它是如何做到这一点的?本:我尝试使用页眉功能,但仍然没有成功。你找到了解决方案吗?我认为缓存不是这里的问题,我在开发者设置中禁用了chrome中的缓存,但当我按下后退按钮时,我的浏览器在注销后仍将进入安全页面。所以缓存不是问题。最好的方法是使用一个基本控制器(MY_controller扩展CI_controller),并在MY_控制器的构造函数上添加$this->output->set_头。然后anycontroller扩展我的\u控制器