Wednesday, 05 August 2015Written by Alan Foster

Have you ever wondered how Joomla cache works and how you can speed up your website using the built-in caching features incorporated into Joomla? If yes then you may find the information included in this blog post useful.

How does caching work?

Every time someone visits your website Joomla has to generate a number of MYSQL database queries, read and process PHP code plus much more in order to render the website correctly for each website visitor.

All this takes time and impacts the speed of the website but you can reduce this overhead by up to 50% by enabling caching at the website.

Caching basically takes a snap shot of the website and stores all the information in a number of files which get stored and retrieved from the hard disks web hosting space.

This can make the website pages load up to 10x faster as there is no longer a requirement to generate as many MYSQL database queries or process as much PHP code in order to render the website. Some database quires will still get generated and some PHP code will still need to be processed but a lot less when you have cache enabled.

Useful information about the Joomla cache options

  1. By default caching is not enabled. You need to enable the built-in caching features included in Joomla.
  2. Cached content is only displayed to visitors who are not logged into the website. Logged in visitors will not be provided with the cached content.
  3. It does not apply to the Administrator area of the website.
  4. All cached content is stored and retrieved from the /cache/ directory.
  5. Caching is split into the following key areas page caching, View and Module caching.
  6. The system cache plugin takes precedence over global configuration and module cache settings.

We have put together a video tutorial for this article which you may find useful. To find out more watch the Joomla cache explained video

Page caching (System page cache plugin)

Page caching (system cache plug-in) basically takes a snapshot of the whole page including the templates, components and modules.

This option gives you no control over the module cache settings or over the progressive or conservative options included in the global configuration settings.

If you have a website with static content and only publish an article now and again then this is a good option for you. As and when you publish new articles or make updates at Your website you can always quickly clear the cache.

How do I use the system page cache plugin?

  1. Log into your Joomla Administrator area.
  2. Select the Extensions menu and Plugin Manager Menu.
  3. In the search field enter "page cache"
  4. Open the system page cache plugin.
  5. By default it will be disabled. Select the drop down option from the left hand side of the page and choose enabled as show in the screen shot below.

Browser caching

You also have the option to use "Use Browser Caching" if you enable this option your site will send a "304 not modified" header to the visitors browser if the page has already been cached in the visitors browser. Basically the cached version of the page will be retrieved locally from the visitor’s computer rather than the server. By enabling this option the site will seem even faster to the visitor.

View and module caching

The view and module caching settings are different to the page caching option so don’t get confused between the two options. Page caching gives you no control over how the content is cached.

View and module caching gives you more control and flexibility over the content included in the Module positions published at your website. For example if you have Facebook or twitter feed module which is updated every few minutes then you would open the module and disable caching for the modules. The system cache option does not give you the freedom to do this where the view and module option does.

How do I use the view and module caching options?

  1. From the Joomla administrator area select the System menu and the Global Configuration menu item.
  2. Select the System tab and you will now see the Cache Setting options.
  3. As noted above by default Joomla caching is disabled.
  4. To enable cache select ON conservative caching or ON progressive caching

 

 

 Whats the difference between conservative & progressive caching?

Conservative caching

This option allows you to choose which modules are cached. You can open each module and enable or disable caching for the module. Conservative is the best option if you have content which is frequently updated, example Facebook feed or twitter feed.

Progressive caching

This option takes a snapshot of each set of modules published to your pages at once. This option affects all modules including the cache module settings. The Progressive option is useful for websites which have static module content. If the content included in the modules change all the time use the Conservative option.

What about the cache life settings?

The cache lifetime is the number of minutes which the cached content is displayed to the visitor. Example if the cache lifetime is set to 15 then every 15 minutes a new cached version of the content is displayed to the visitor. So if you have a website using a twitter feed module or Facebook module which gets updated a lot use the Progressive option and disable caching in the module. You may also want set the cache lifetime to maybe 5 or 10 minutes.

How do I clear the cache?

  1. From the Joomla administrator area select the System menu.
  2. You will see the options to Clear cache or purge expired cache.
  3. The clear cache option will clear all cached item’s where the purge expired cache option will only clear the items which are still current.

Which cache option should I use for my website?

It really depends on the type or website you run. If you run a website which has very static content that rarely changes then enable the system page cache plugin. If you have module content which changes all the time like Facebook comments or a twitter feed then disable the system page cache plugin and use Conservative caching with a short lifetime.

Joomla cache extensions

If you want even more control and flexibly over the way the content is cached at your Joomla website take a look at popular Jot Cache or Cache Control extensions.

Another extension worth noting is the Cache Cleaner extension which allows you to clean the website cache with a click of a button.

Conclusion

I hope i have not blown your head off trying to explain how caching works for Joomla. I have tied to make it as easy to understand as possible so everyone can take advantage of this built-in feature to speed up their website.