Joomla is one of the most popular content management systems (CMS) on the web at the moment. However, it is surprising how often Joomla websites are not optimised for performance and just left in there default installation state.
Web caching has been around for quite some time, yet is often overlooked by many webmasters when they complete their website. Caching is a very effective method of increasing performance of dynamic, script based websites as it can greatly reduce the CPU and disk read requirements of a website.
With caching turned on, huge performance gains can be achieved because the web server only needs to process the script/s (PHP) and, quite often, the database (MySQL, PostgreSQL, etc.) on the first time the page is accessed. After that, each time the page is accessed by a site visitor, the cached version is simply read from RAM or disk and sent to the visitor.
The administrator of the website usually sets a default period for which the server should keep the cached page (i.e. 4 hours), after this time the file is removed and regenerated on the next user visit. This is usually referred to as the Time To Live (TTL), or in Joomla talk, the Cache Time.
In addition to the Cache Time, caching systems like the one built-in to Joomla can also detect when the content of a page has been edited, for example, when you make changes to an article, which will notify the cache system that the corresponding cached page is no longer valid. Thus, it will be removed and regenerated on the next user visit.
Joomla 1.5 ships with a number of caching features that allow a webmaster to increase performance of their website, often providing significant performance improvement over non-cached versions of the same content.
There are three options available when it comes to Joomla’s built-in caching options:
- Page caching
- Module caching
- View and Module caching
The options complement each other and, for optimum performance, should be used in conjunction with one another.
When a page is first requested by a website visitor, the page caching feature creates a file containing the final output version of the page and, by default, saves it to the web server disk. This file is then called from the cache for subsequent visits to the page by any visitor.
The page is kept in the cache for the amount of time specified by the website administrator, or until a change is made to the article.
Page caching can be enabled and configured by going to:
Extensions -> Plugin Manager and selecting to edit the System – Cache plugin.
You must set the plugin Enabled option to yes in order to benefit from page caching. You can also set the following under the Parameters options:
• Use Browser Caching – also enables caching of the page on your visitors computer.
• Cache Lifetime – the default time, in minutes, to keep a page in the cache.
Module caching is available for the majority of Joomla modules that provide some output to the website user. The caching mechanism works in the same manner as the page caching feature above, but can be turned on or off for each individual module. You can also, sometimes define the ‘Cache Time’ on a per module basis, but this is quite a rare feature.
The module caching settings can be found by going to:
Extensions -> Module Manager.
Select the module you wish to view and then look for the Caching option under Parameters or Advanced boxes.
View and Module Site Wide Caching
Site wide views and module caching can be configured in order to ensure that your site template files are also cached and modules are provided with default caching parameters. This can be done by going to:
Site -> Global Configuration and selecting the System tab.
On this page there is a Cache Settings box on the right hand side with the following settings:
- Cache (Yes / No) – whether to enable site wide caching.
- Cache Time (X Minutes) – the site wide default number of minutes to cache items for