i’m create some easy method for clear page caching by extend from CI_Output
1. create file in System/Application/Library
/system/application/libraries/My_Output.php (“My_” is your library suffix name)
2. extend from CI_Output
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* Clear Cache
*
* Responsible for sending final output to browser
*
* @package CodeIgniter
* @subpackage Libraries
* @added-by Chitpong Wuttanan (<a href="http://lab.tosdn.com">http://lab.tosdn.com</a>)
*/
class My_Output extends CI_Output {
function clear_cache($set_uri = NULL){
$CFG =& load_class('Config');
$filepath = ($CFG->item('cache_path') == '') ? BASEPATH.'cache/' : $CFG->item('cache_path').md5($set_uri);
if(file_exists($filepath)) {
@unlink($filepath);
log_message('debug', "Cache deleted for: ".$set_uri);
} else {
return FALSE;
}
}
}
?>3. how to use page caching
$this->output->cache(60); //1 Hour
$this->load->view('profile.php');4. how to clear page caching
$this->output->clear_cache('http://www.web.com/profile');
// "http://www.web.com/profile" is URI page for clearingReference Page Caching with CodeIgniter and Cache Clearing code