Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Codeigniter Disable Cache

I'm trying to learn Codeigniter and understand the basics so far, but as I try to test, it seems the cache is getting in the way. Normally when I test on localhost I make a change and instantly can see it in browser, but with Codeigniter it seems I have to wait ~1 minute for changes to be seen in browser. Is there a way to universally disable the Codeigniter cache so when developing changes happen immediately?

like image 380
kaarch Avatar asked Nov 04 '13 19:11

kaarch


People also ask

What is the command to clear cache in CodeIgniter?

Clearing a cached path You can clear any specified path of its cache by calling $this->output->clear_path_cache('path/to/clear'); . This method will return boolean TRUE if successful, FALSE if not.

How does cache work in CodeIgniter?

CodeIgniter lets you cache your pages in order to achieve maximum performance. Although CodeIgniter is quite fast, the amount of dynamic information you display in your pages will correlate directly to the server resources, memory, and processing cycles utilized, which affect your page load speeds.


1 Answers

Just put this code in the __construct function of controller

$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, 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");
like image 118
vivex Avatar answered Nov 04 '22 11:11

vivex