Written by Max Milbers. Posted in Concepts

General notes to caches

A cache is in general an idea to save already computed work and to be able to load it very fast.

In our computers we have really a lot of different caches. CPUs had just a Level1 cache, modern CPUs have usually a big cache stepped in 3 levels. Even our storage has a cache. Servers have bigger hardware caches than desktop computers. Just to give an idea, why servers are faster for serving webpages even with less GHz than the normal desktops. When we talk about caches it is very important to say which kind of caches. The whole chapter of caching has a lot todo with correct understanding of the basics.

Before the joomla page is even installed, there are usually already some software caches available. Which module is suitable depends already on the used server software. Usually apache or nginx, both have caching abilities on server level. But it is quite hard to get some of them correctly working for php pages.

Joomla itself has a caching system, which is even extendable by plugins. This system can be configured in the joomla main configuration. The cache stores parts of the already rendered html as file. The "progressive caching" should not be used! It is creates a cache file for any rendered page per user. So any user has no cached file for the first call. This makes no sense, because users do not tend to browse the same pages. It is very likely that they leave the store before they find out, that loading the category a second time is a lot faster. The classic cache works so, that the rendered pages are stored user independent. This lowers the server load and can be a lot faster. VirtueMart uses this plugin system of joomla. Some cache calls ignore the setting of joomla (for example the vm news feed and the categorytree), because the cache is automatically cleared and delivers not a ready rendered page, but a function results. Developers can delete this caches in the joomla cache overview like normal joomla caches if needed.

It is important to check the cache settings of any joomla module, when it is planned to use the cache system. It makes a lot sense to cache the currency switcher, but it is crucial to disable caching for the cart module. Also the cart or user pages should not be cached. The product module is also such an example, there is an extra cache setting, which actually configure how often the module will display different products. When the normal page cache is set to 15 minutes, the featured products would change any 15 minutes. But you can set the vmcache for that module to 5 minutes. So when configuring the caching for modules keep in mind that a cached content can be delivered to wrong users and also stops modules publishing updated values.

It is important to know that VirtueMart has a lot static caching variables to deliver the already produced result directly. Lets say we display a product group, derivated from one parent, then the parent product is loaded only once for all children. This is also very important to developers, sometimes the cache can be nasty and lead to unexpected results. In this case lets find a solution so that the key of the cache is more sophisticated or if there is no solution, we still can add the hammer method "empty the cache variable"