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


PHP Codeigniter is showing the cache when i press the back button after I logout

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

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

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

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');
}

但当我按下后退按钮时,缓存仍然存在。我该怎么解决这个问题?

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

我认为缓存不是问题所在,我在开发人员设置中禁用了chrome中的缓存,但当我按下后退按钮时,我的浏览器在注销后仍会转到安全页面。

所以缓存不是问题。。

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

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

只需将其添加到控制器

 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');
    }

REad我认为这对你非常有用

https://www.codeigniter.com/user_guide/libraries/caching.html

https://www.codeigniter.com/user_guide/database/caching.html

试试这个

$this->cache->clean();

$this->db->cache_delete_all();