Joomla's caching system can be a huge benefit to your site, but can also cause a lot of headaches. The advantages are obvious: an overall better user experience, faster load times, less powerful server requirements and more. We're not going in-depth on the benefits here though. Let's talk about some of the pain-points that you should know about when trying to get Joomla's caching setup.
Caching is simply storing chunks of data, usually HTML meant to output to the user, to be used for future page loads. By storing generated HTML, your server can skip huge portions of PHP code that would ultimately end up generating the same HTML code.
In short: It's much easier to load data that's already been created instead of creating it new for each request.
It's important to know that all Joomla caching settings, except browser caching (see below), only work for guest users. If a user logs into your site, any HTML output that is cached is not reused.
Joomla will fully generate each page for a logged in user. That is necessary so that your site can show the user's name, avatar, discussions relevant to that user, shop pages and whatever else is specific to that user.
This is one of the most important items to know since, if you think you're having issues with caching, you'll usually only see it when you are not logged in. For other debugging tips, see below.
There are many levels to Joomla's cache system, each mostly focusing on a portion of rendering the page, and each able to cause you huge headaches. There is other data-specifc caching that can be done by each extension, which I'll address briefly, but it's not the focus here since that's not as general a case as the system-wide Joomla caching.
The descriptions below go from light-touch, little bits of strategic caching as necessary to heavy-handed, using a giant hammer with possible collateral damage caching.
In the Global Configuration area of Joomla is a simple "Cache Settings" option. For the best overview of each of these options, please see OSTraining's excellent Joomla Cache Options Explained post. For our purposes, we're just curious how each of those settings can hinder your site.
From a performance perspective, this is the worst. From a headache perspective, this is the best. Joomla works on every page load to create the output that the user sees. This means that there shouldn't be any hiccups (caused by caching) to worry about.
Conservative caching for Joomla should cache the output of each module, with the ability to disable caching for individual modules. This ability to disable is hugely important because some modules just shouldn't be cached.
Take for instance, menu modules which automatically show all the sub-menus for the specific section of the site you are in. When caching is enabled, the sub-menus for one section can get cached and then, when a user visits a whole other section of the site, the wrong-submenus are simply read from cache and shown.
This caching mode will try to cache output for all modules on a page without any individual settings. Here, you'll run into issues where a specific module should have different contents frequently, like a "Latest Posts" module for a forum. If you have your cache time set for a very long period, the new posts will not seem to update often enough.
With Conservative caching, you could individually disable caching for your "Latest Posts" module, but with Progressive caching, you can't. Some caching improvement, with less flexibility and control.
By far, the biggest culprit of problems is this plugin. When enabled with the default settings, it will cache the full-page HTML output for your site. This can lead to dramatic speed boosts as your server only needs to generate the HTML for each page infrequently.
It can cause big problems with sites that use dynamic content (blog posts that update frequently, discussion groups, etc) since the output may seem much more static than it really is.
If your site has any actions that a guest user can take, this plugin should be disabled. Since the full output is cached, if a guest is able to submit a form, create a post or comment or do anything else, the updated content may not be shown for minutes or even hours (depending on your cache timeout).
This setting within the System - Cache plugin will instruct browsers to cache the received page from your site and use it before trying to re-load it from the server. While that sounds nice since you're server is not even involved at this point, the results can be disastrous!
For any site with user authentication, browser caching must be disabled.
You read that right. The problem here is, let's say, a guest comes to your site and loads your home page. The browser then caches that page. Once they login, if they return to the home page, the original not-logged-in version will be shown the to user from the browser cache. If they visit other pages of the site, they may seem logged in and may not.
Generally, we recomend disabling browser cache always unless you really, really know what you're doing.
Whenever you run into an issue on your Joomla site, even if you don't think it's a cache related one, you should disable all caching on your site. If you leave caching on, you may be masking any fixes you change until the cache updates. We run into this when helping users all the time; we provide a solution but the user thinks it doesn't work since the old cached output still shows.
If you find an issue that is cache related, narrow it down by disabling cache starting with the most agressive caching (browser caching) down to the lightest (conservative caching). At each step, make sure you use the Maintenance -> Clear Cache setting in the Joomla admin area to make sure that the old cache is deleted.
Well, that's it. After over a 1000 words, I'm not sure if I actually made sense or made things more confusing. There's so much more to caching, so many problems it can cause that aren't mentioned (Invalid Token, anyone?) and so much more it can do like caching database queries. It's just not possible to cover it all in one sitting without driving you (or myself) insane.
I'd love to talk more about caching if it's something you want to learn more about. What areas are you most interested in? What ares are the most like a black-box? Let me know below and I'll try to answer in a reply or create another dedicated post!