Welcome Guest, Not a member yet? Register   Sign In
Web Page Caching
#1

(This post was last modified: 08-14-2017, 03:02 AM by bishal.)

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.
Reply
#2

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.
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply
#3

(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.
 
Reply




Theme © iAndrew 2016 - Forum software by © MyBB