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->output->clear_all_cache();

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->output->clear_path_cache($uri);

 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"

Comments

  1. When i try
    $this->output->clear_all_cache();
    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.

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

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

    ReplyDelete

Post a Comment

Popular Posts