FUEL CMS User Guide : Version 1.5.2


Caching

CodeIgniter, is well-known for it's fast performance as a framework. However, there are some instances where you may want to cache a page or file to prevent excessive database queries and HTTP requests for javascript and CSS. To help with this, FUEL provides several method to cache resources and thus speed up page speed.

Programmatically, you can access the FUEL's cache methods through the instantiated Fuel_cache object like so:

$this->fuel->cache->clear_all();
$this->fuel->cache->save('my_cache_id', $data);

Page Caching

FUEL provides several options for caching your pages. The default setting, which can be altered in your fuel/application/config/MY_fuel.php file by changing the $config['use_page_cache'] parameter, is to cache all the pages created in the CMS. In some cases, you may not want to cache the page (e.g. you have a section that you want to be random on each page), and in those cases you can set the page's CMS cache setting to no.

Block Caching

Similarly, blocks can also be cached as shown in the example below:

echo fuel_block(array('view' => 'my_block', 'cache' => TRUE));

Template Compiling

Both pages and blocks can take advantage of the template parsing library to allow users to safely use limited PHP functionality. These template files get compiled and are stored in the fuel/application/cache/dwoo/compiled folder.

Asset Optimization Caching

The Asset class provides several options to speed up your CSS and javascript files of your pages by changing the assets_output property which has the following options:

A writable assets/cache folder must exist for asset caching to work. Also, cached asset files must be deleted either manually or by the CMS's Clear Cache utility.

Cache Clearing

Sometimes you may make changes and not see them reflected on the site. If so, you may need to clear your site's cache. To do that, click on the Page Cache menu item under manage and then click the Yes, clear cache button to clear your sites cache files.

Alternatively, you can use the command line to clear the cache:

php index.php fuel/manage/clear_cache

Web Hooks

The FUEL configuration's webhook_remote_ip parameter gives you the ability to set one or more IP addresses that can be used to remotely call the fuel/manage/clear_cache. For example, say you use Beanstalk to manage your GIT repositories and you would like to automatically clear the cache upon commit. You can set this configuration value to the IP address ranges provided here. Then, in Beanstalk you can set up your web deployment post hook. In this case you would set it in Beanstalk to be the full URL path:

http://www.mysite.com/fuel/manage/clear_cache