Reputation: 117
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?
Upvotes: 8
Views: 31237
Reputation: 2515
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");
Upvotes: 12
Reputation: 19
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
class MY_Cacheoff extends CI_Cacheoff {
/**
* author: https://www.blazingcoders.com
*/
function disable_cache() {
$this->set_header('Expires: Sat, 26 Jul 1997 05:00:00 GMT');
$this->set_header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
$this->set_header('Cache-Control: no-cache, no-store, must-revalidate, max-age=0');
$this->set_header('Cache-Control: post-check=0, pre-check=0', FALSE);
$this->set_header('Pragma: no-cache');
}
}
For Detail Explanation check the link
Upvotes: 0
Reputation: 20475
IF you enabled the cache, you need to disable it (comment out the cache). Otherwise it may be your browser caching, you could force a SHIFT-F5 (in most browsers).
The cache will only work if you have it so defined in your controller etc; not randomly.
Upvotes: 0
Reputation: 12305
Just delete all the cached items in the application/cache folder:
http://ellislab.com/codeigniter/user-guide/general/caching.html
Upvotes: 0