This site might not be up to date. New documentation sites are being created: for developers and for users.

Vahemälu

From Joomla! Documentation

This page is a translated version of the page Cache and the translation is 1% complete.
Outdated translations are marked like this.

Joomla has different ways of caching "things". Here is an overview for administrators and developers – what, where and when.

As an administrator, Joomla provides you with the ability to cache parts of your site. You can choose to cache whole web pages or just parts of those pages. This guide explains how.

On a Joomla site web page there are 3 things that may be cached:

  1. The whole page itself – the Page cache
  2. The output from the Joomla component for that web page – known as the View cache
  3. The output from the modules shown on that page – known as the Module cache

You have a number of cache settings that allow you to control what gets cached:

  1. The system plugin System – Page Cache
  2. The Global Configuration, System tab, Cache Settings. Here the System Cache option may be set to
    • OFF – Caching disabled
    • ON – Conservative caching
    • ON – Progressive caching
  3. Many modules within their options have an Advanced tab in which the Caching can be set to Use global or No caching

As described below, there are also rules for caching that are implemented within the Joomla code, and over which you have no control.

You can clear the cache through the Administrator  System  Clear Cache menu selection.

In general, you can think of Joomla having 3 levels of cache, increasing in aggressiveness

  1. Conservative caching
  2. Progressive caching
  3. Page caching

We'll look at these three in detail below.

In addition, Joomla developers can use caching facilities to store the result of database queries, for example, to increase the responsiveness of the site, but this is outside the scope of Administrator capabilities.

Page Caching

To switch this on, go to Administrator  Extensions  Plugins. Then find the System – Page Cache plugin, and enable it. This means that site pages will now be cached and whenever they're requested again, the cached page will be served, rather than it being generated by Joomla from the information in the database. The cached page will continue to be served until it's expired – as defined by the Cache Time parameter in the Administrator  Global Configuration  System tab  Cache Settings.

If you're reading this page as a tutorial and want to test the page caching, it's best to set the Global Configuration cache settings to:

  • Cache Handler – File
  • Path to Cache Folder – leave blank
  • Cache Time – 15 (the default of 15 minutes)
  • Platform Specific Caching - No
  • System Cache – OFF – Caching disabled

To verify that page caching is working, go to a website page that displays an article. After you display that page you should find in the file system a cache/page directory with a file in it that has a filename like <string of hex digits>-cache-page-<string of hex digits>.php. (Joomla has to store separate cache pages for separate URLs so the second string of hex digits is a hash of the URL of the site web page, to make the filename unique to that page).

Then use the Administrator functionality to change the text of that article, and redisplay the site web page. You should find the cached version, not your modified text.

Changing an article (or other Joomla item) does not clear the page cache for the web page(s) where that article is displayed. To clear the page cache go to Administrator  System  Clear Cache. Click on the checkbox next to the Cache Group called "page", and press the Delete button. When you redisplay your web page it should now show your amended text.

If your site has a function like a shopping basket, applying page caching will cause problems, as pages have to show what the customer has already selected, rather than displaying a cached page that is common to everyone. However, you can configure the System - Page Cache plugin to exclude caching specified Menu Items or specified URLs and URL ranges (in the Advanced tab), so that only truly static pages are cached.

Conservative Caching

With Conservative Caching you can cache the View output from components and the output from those Modules that allow caching. But note that this will work only on pages that are not cached using the Page Cache. For those pages the whole web page is cached, and Conservative Caching isn't even considered.