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.

$this->output->cache($n);

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.

Tutorial Pace is Pakistan's first and only platform from where you can learn market demanding technologies right from developers. Tutorial Pace is developed by a developer for developers. We are working to maintain the quality of content and practical knowledge within our tutorials.