tarek nasif
tarek nasif

Reputation: 59

How do I tell Codeigniter not to store cache?

I have a Codeigniter 2.2 project. without no changing in the code my browser somehow holding cache for previous logged user. If i reload with clearing cache then it shows currently logged user.

I have added My_Output core controller. and added $this->output->clear_cache() in the logout function. I have also added

 <IfModule mod_headers.c>   
Header set Cache-Control "no-cache, no-store, must-revalidate"  
Header set Pragma "no-cache"    
Header set Expires 0 
</IfModule> 

in my .htaccess file. Still same problem

Upvotes: 0

Views: 1405

Answers (2)

jones
jones

Reputation: 755

     $this->CI =& get_instance();   
     $this->CI->session->sess_destroy();
     $this->cache->clean();
     redirect(base_url());

Upvotes: 0

lalit mittal
lalit mittal

Reputation: 444

You have to send the proper headers to the client.

$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");

Upvotes: 3

Related Questions