In this tutorial we will learn about the CodeIgniter Page Caching. Caching a page increases the load speed of the page. If the page is cached, it is saved in its entirely rendered state. The next time the server receives a cached page request, it is sent directly to the requested browser.
Application/cache folder stores cached files. Caching can be activated on a page basis. While enabling the cache, we need to set the time to remain in the cached folder and delete it automatically after that period.
Enable CodeIgniter Caching
Caching can be activated by running the following line in any method of the controller.
If $n is the number of minutes, you want to keep the page cache between refreshments.
Disable CodeIgniter Caching
Cache file is deleted when it expires, but you must disable it if you want to delete it manually. By executing the following line, you can disable caching.
// Deletes cache for the currently requested URI $this->output->delete_cache(); // Deletes cache for /foo/bar $this->output->delete_cache('/foo/bar');