This article provides you with an in-depth analysis of how caching works, plus how to set it up in Joomla for optimal performance.
Joomla and almost all other CMS's are PHP / MySQL based, which means that in order to generate the necessary HTML to show to the user, a lot of processing has to be done first, first pulling the article data from the database, the same for the modules, and then composing this into one HTML page. This is why completely static HTML sites are usually faster. Caching tries to overcome this by re-using the earlier generated HTML from Joomla.
This usually speeds up the load time of a webpage, but the disadvantage could also be that a user looks at a stored view, while the actual page has been changed in the meantime. Whether or not this is a problem depends per site. When you are busy developing a site, making a lot of changes, it is usually best to leave caching switched off (by the way, caching is not enabled for signed-in users). Also, there could be functionality that does not work well with caching, like some captcha's, forms and webshop extensions (Virtuemart, Hikashop etc).
For this reason, a default Joomla installation ships with caching switched off. Joomla core offers a number of possibilities to use caching, in multiple locations: per Component, per Module or per Page. The stored views for this are stored in the filesystem, in the /cache/ folder, as you can see when caching is switched on. You see a number of folders and files sitting there usually:
You can see com_* for component views, mod_* for module views and page for full-page views. When you examine the files in these folders, you can actually recognize the pre-generated HTML content. Note that you cannot just access these files directly, they need to be serverd by Joomla.
When you actually want to use caching, you can activate it on multiple levels. Note that many hosts also offer server-side caching mechanisms (like Varnish, or Siteground's Supercacher). I usually choose either Joomla cache or the Varnish / Supercacher solution, but not both. That does not make sense and can be a source of conflicts.
Joomla Global Configuration - System tab - Cache Settings
First, you will set a global setting. This setting controls the component-caching. Joomla offers 3 possibilities to use caching here:
0 - Off
1- Conservative caching
2- Progressive caching
Progressive caching can cause unexpected issues in rare cases, so it is advised to use the conservative option. This turns on caching for the component and modules. It also allows you to override the global cache setting per module while progressive does not allow this, as it stores a cache view of the combined modules.
The Cache Handler can only be set to "File". Joomla actually offers more options (like mem-cache for database caching, scroll down for more information), but it takes advanced users to enable this, with additional plugins and set-up.
What is worth looking at is Cache Time. The default is 15 minutes, but for sites that are not updated often, you could set this much higher.
Platform specific caching
A new option that has been added in Joomla 3.5 is Platform specific caching. When you leave caching disabled you won't notice it, but if you enable it, a new option appears:
Use this option when you offer device-specific content. Maybe you make sure some modules only load on non-mobile devices. Then this option prevents caching issues between devices, like mobile users getting a cached version of a desktop view. Note that most users don't need this option, also when you are using CSS to hide things with classes like hidden-phone.
On a per module basis, you can override the Global setting for cache (if you have set global cache to conservative). You can only switch it off when on a global level it is switched off, not the other way around. Note that the override mechanism does not work well when the System - Cache plugin is switched On.
System - Page Cache plugin
The System - Page Cache plugin plugin switches on caching for the whole page being accessed. This can speed up your site considerably. However, especially for pages that need interaction with the user (like a contact form), or non-static content, issues are known, so test carefully. Also, the stored views can increase the size of your hosting-account. Best use is for simple, small, static sites, but many sites are like this: on Joomlaseo.com the plugin works perfectly. Read this post by Yireo to read about some of the disadvantages.
Activation is easy: in the Plugin Manager, look up the "System - Cache" plugin and enable it. Optionally you can switch on the "Use browser caching" option, but it is only useful for sites where users often return to a page that they already accessed within a browsing session and it can also cause issues, so best is to leave it switched off.
Periodically, you may have to clean your cache. An example could be when you are editing an article in the backend and you want to see the changes on the frontend. If you have set your cache waiting time to 15 minutes, this means that you would have to wait 15 minutes to see the changes. To clean the cache before that, you can go to System >> Clear Cache. Select all entries shown and then click the Delete button. Now you can see your changes.
However, all this is very tedious if you have to do it multiple times. A very clever solution has been created by NoNumber, with the Cache Cleaner plugin. It allows you to clear cache from within every part of the backend, even from within an article you are editing. Even more, you can set it to clean automatically every time you perform a Save action, or after a set timeframe, like every hour or so. Finally, in the Pro-version, it is even capable of clearing 3rd-party cache, like your CDN, or Siteground cache!
Memcache for advanced users
Advanced users can activate memcaching if their webserver supports it (Siteground does). It speeds up database calls, API calls and page rendering by storing data and objects in the server's RAM in order to reduce the number of times a database is queried.You will first need information from your server: the local IP-address (usuually localhost or 127.0.0.1) and the memcache port (5 digits usually). With this information you should then manually edit your configuration.php file, there are no default options for this in the Joomla menu. Update the information as follows:
PHP version lower then 7:
public $caching = '2';
public $cache_handler = 'memcache';
public $memcache_server_host = 'localhost';
public $memcache_server_port = 'xxxxxx';
PHP version 7 and up (note the extra "d"):
public $caching = '2';
public $cache_handler = 'memcached';
public $memcache_server_host = 'localhost';
public $memcached_server_port = 'xxxxxx';
Make sure you check the site still works well of course, sometimes there are issues or conflicts with your extensions. Mostly this goes fine though, and the site should be a lot faster.
Joomla extensions for Caching
For specific purposes, you can install a caching-extension from the Joomla Extension Directory. This can be especially useful if parts of your site need to be cached, but others not, requiring a per menu item level of caching. Or maybe you need to have different levels of caching per browser, or mobile devices.