Caching forever until the file has been edited by the backend - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: Caching forever until the file has been edited by the backend (/showthread.php?tid=57103) |
Caching forever until the file has been edited by the backend - El Forum - 02-14-2013 [eluser]Unknown[/eluser] I have created a web site using code ignitor. It does not require any user interaction on the front-end however there is a backend where my client will login to add and edit data. I want to always serve a cached file to the user agents and refresh the cache every time that the client edits from the back end. How do I set caching to not refresh the cache ever with Code: $this->output->cache(n); Caching forever until the file has been edited by the backend - El Forum - 02-15-2013 [eluser]Otemu[/eluser] Hi, Doesn't seem there is an option to cache the page forever, you could put an extremely long number: $config['cache_expiry'] = 100 * 1440 * 365; $this->output->cache($config['cache_expiry']); This will set expiry time to about a 100 years. When someone edits/updates the page then you would need to delete the cache file, maybe run a function on update that checks if a cache file exists and if so delete that file. Also check out Phil Strurgeon cache library seems to be quite popular: https://github.com/philsturgeon/codeigniter-cache Caching forever until the file has been edited by the backend - El Forum - 02-15-2013 [eluser]CroNiX[/eluser] In addition to what Otemu suggested, which is what I do, after something is saved in the backend and the cache file deleted, I issue a file_get_contents(url) so that the cache gets rebuilt by hitting the url at that time instead of the next time someone visits the page (so it's always cached for visitors). |