Reputation: 12034
My clients's website is done with CodeIgniter. Problem is: any time I make some changes, I need to empty the 'cache' folder.
I know you can disable cache in a controller:
$this->output->set_header('Last-Modified: ' . gmdate("D, d M Y H:i:s") . ' GMT');('Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0');
$this->output->set_header('Pragma: no-cache');
$this->output->set_header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
$this->output->set_header
But how to disable it Globally to the WHOLE website ?
Upvotes: 0
Views: 6806
Reputation: 631
Create the file /application/core/My-Output.php that has the following lines:
class MY_Output extends CI_Output {
function _display_cache(&$CFG, &$URI)
{
/* Disable Globally */
return FALSE;
/* OR - Disable for a specific IP Address */
if ( ($_SERVER['REMOTE_ADDR'] == '127.0.0.1') || (eregi("192.168.", $_SERVER['REMOTE_ADDR'])) )
{
return FALSE;
}
/* OR - disable based on a cookie value */
if ( (isset($_COOKIE['nocache'])) && ( $_COOKIE['nocache'] > 0 ) )
{
return FALSE;
}
/* Call the parent function */
return parent::_display_cache($CFG,$URI);
}
This will override the global output handler in your CodeIgniter application in any way you desire.
Upvotes: 0
Reputation: 101
you can globally disable whole website cache by using htaccess
<FilesMatch "\.(html|htm|js|css|php)>
FileETag None
Header unset ETag
Header set Cache-Control "max-age=0, no-cache, no-store, must-revalidate"
Header set Pragma "no-cache"
Header set Expires "Wed, 11 Jan 1984 05:00:00 GMT"
</FilesMatch>
Upvotes: 5