Warning: Don't take this as gospel, I'm simply stating my observations, but would appreciate if someone who knows the inner workings could commentnifini, you're right, and I'm glad you pointed that out... which has lead me to a question about Joomla's caching system. As far as I can see there are two places to set caching settings, System Cache and Global Cache (which can be turned on/off per module).
System Cache seems to place its output in /cache/page
Global Cache places its output in /cache, but filed under com_content, mod_mainmenu, etc.
Now looking at files produced by each it seems as though Global Cache caches individual "parts" depending on the URL, so for a particular request the state of the menu at that moment will be cached, the state of the content will be cached, etc. These "parts" are stored in cache files that look something like this:
| Code: |
a:2:{s:6:"output";s:0:"";s:6:"result";s:779:" <div>some html here!</div> ";}
|
Those fancy numbers at the beginning are obviously info that tell Joomla how to reconstruct the page. All of this implies that Global Cache tells each part of the page to be cached separately, and then when you access the same URL again the page is rapidly pieced back together and presented to you.
NOW, System Cache seems to behave differently! It seems (even with Global Cache switched off) to simple take a snapshot of the entire page after load. It then stores a hash of the URL you used to access the page, and so when you next view the site, if your request URL matches one in the cache (that hasn't expired) you just get shown the cached file instead of rebuilding it but executing all the plugins and modules again! We could say that this is a more simplistic approach than the Global Cache, but pretty efficient and robust though. In fact, I'd argue that the only time that this approach is worse off that using Global Cache would be when most of your page remains the same but one tiny little module's content changes depending on a GET parameter in the URL. So this means that System Cache will see different requests and therefore build more cached pages, even though they're MOSTLY the same. Having said this, I'm not sure that Global Cache is smart enough to mix and match content that hasn't changed (get it from the cache) and a module that has changed (rebuild it but executing the module) depending on a GET parameter that affects ONLY the module. Can it do this?
If you look at the contents of the files in /cache/page/ you'll see that a complete snapshot of the fully rendered page is saved. Contrast this with the approach of Global Cache where individual "parts" are saved and then have to be reconstituted later. This finally leads me to my questions about Joomla's caching...
- Are Global Cache and System Cache supposed to be enabled simultaneously?
- Does Global Cache take precedence over System Cache?
- Can there be any downside to leaving Global Cache off and enabling System Cache only?