CodeIgniter Forums
Web Page Caching - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5)
+--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24)
+--- Thread: Web Page Caching (/showthread.php?tid=68697)



Web Page Caching - bishal - 08-14-2017

Hello Everyone.
                    I'm trying to cache the html output, I tried this as mentioned in CI document by keeping the code '$this->output->cache(100);' on controller. This do created the cache file under application/cache directory with random file name as expected but now I need this file to be deleted whenever I alter the database i.e (insert, update, delete). 
                   How can I achieve this. I manually tried to delete the file by writing this code ($this->output->delete_cache()), as mentioned in document this should delete the cache file for the currently requested url but this didn't work. I created the cache file on default controller.


RE: Web Page Caching - InsiteFX - 08-14-2017

I think you need to specify which cache to delete like below:

PHP Code:
// Deletes cache for /foo/bar
$this->output->delete_cache('/foo/bar'); 

To enable the profiler place the following line anywhere within your Controller methods:


PHP Code:
$this->output->enable_profiler(TRUE); 

This should tell you the name of your cache but not sure, untested.


RE: Web Page Caching - bishal - 08-15-2017

(08-14-2017, 04:15 AM)InsiteFX Wrote: I think you need to specify which cache to delete like below:

PHP Code:
// Deletes cache for /foo/bar
$this->output->delete_cache('/foo/bar'); 

To enable the profiler place the following line anywhere within your Controller methods:


PHP Code:
$this->output->enable_profiler(TRUE); 

This should tell you the name of your cache but not sure, untested.


Thank You for the response. I managed it to work some how. I created the helper function that deletes every cache file recursively and I called that function after every update and insert query.