CodeIgniter Force Clear Browser Cache

Sometimes when I make changes in live and want visitor to clear their browser cache to see latest changes. I setup http header to expire current cache by setting a back date. here is the code for CodeIgniter. after few days of update I remove this code so browser can cache again. ๐Ÿ˜›

$this->output->set_header("HTTP/1.0 200 OK");
$this->output->set_header("HTTP/1.1 200 OK");
$this->output->set_header('Expires: Sat, 26 Jul 1997 05:00:00 GMT');
$this->output->set_header('Last-Modified: '.gmdate('D, d M Y H:i:s', time()).' 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");

Posted

in

by

Tags: