Friday, April 12, 2013

Flushing CodeIgniter's cache or Deleting Caches in Codeigniter

Enabling and deleting caches in Codeigniter is fairly straightforward and easy. In this post, I am writing about deleting caches. You no longer need to delete caches manually in Codeigniter 2.x version.

If you no longer wish to cache a file in Codeigniter you can remove the cache files. Following are two methods to do it.

Clearing all cache

You can clear the entire cache directory by calling $this->output->clear_all_cache();

Note: This will not remove the .htaccess and index.html files in the applications/cache folder.

//Clears all cache from the cache directory


This method returns NULL.

Clearing a cached path

You can clear any specified path of its cache by calling following method.

//Clears the cache for the specified path


 This method will return boolean TRUE if successful, FALSE if not.

You can find all the information/source-code about clearing cache inside "application/core/MY_Output.php"


  1. When i try
    it is showing
    Call to undefined method CI_Output::clear_all_cache()
    Can you give me solution??
    I have alredy loaded driver library for cache in autoload.

  2. i have same problem of above comment .....

  3. All these methods are deprecated in Codeiginiter 3.xx and do not not exist anymore.