Skip to content
Tutorials Center
My learning

Topics

Lesson 27 of 37 ยท SEO and Performance

Caching and Compression

Speed up Joomla with the right cache: system cache modes, page cache plugin, per-module caching, cache handlers, browser caching headers and compression.

A Joomla page is built on request: PHP loads the framework, queries the database for the article, menu and modules, runs plugins and fills layouts, then sends HTML. Doing all that for every single visitor is wasteful when the page is the same for most of them. Caching stores the result of expensive work so the next request can reuse it, and compression shrinks what travels over the network. Together they are the cheapest speed-ups available.

Joomla cannot run here, so settings are explained by path, and two JavaScript stand-ins let you experiment with cache time-to-live and compression sizes.

Layers of caching

Think of speed in layers, from the visitor backwards:

flowchart LR
    V["Browser cache"] --> CDN["CDN or reverse proxy"]
    CDN --> PC["Joomla Page Cache plugin"]
    PC --> SC["Joomla system cache (views, modules)"]
    SC --> DB["Database"]

The earlier a request is answered, the less work remains.

  1. Browser cache: the visitor's browser keeps CSS, JavaScript and images, controlled by HTTP headers sent by your server.
  2. CDN / reverse proxy (for example Cloudflare or Varnish): serves copies from locations near the visitor.
  3. Joomla Page Cache: a plugin that stores the whole HTML page.
  4. Joomla system cache: stores pieces (module output, component views) in the cache store.
  5. Database query cache and PHP OPcache: server-level help, configured by your host.

System cache

Open System > Global Configuration > System. In the Cache Settings you choose:

  • Cache: Off, Conservative caching or Progressive caching. Conservative stores one cache copy per page address and user. Progressive stores more aggressively and fits sites where pages do not vary by user. If unsure, start with Conservative.
  • Cache Handler: where the data is kept. File works everywhere and is the default; APCu, Redis and Memcached are faster and are required for shared setups when the extension is installed on the server.
  • Cache Time: minutes before a cached item expires (the default is 15).
  • Platform Specific Caching: keeps separate caches for mobile and desktop if your template differs by device.

Individual modules have a Caching setting on their Advanced tab: Use Global, No Caching, and a time. A module that shows user-specific data, such as a greeting or a shopping cart, must not be cached for everyone; extensions that know how to vary the cache by user handle that for you.

To remove cached entries, use System > Clear Cache, which lists the cache groups and has Delete Expired and Delete All. After a template or content change that does not appear, clear the cache before suspecting a bug.

Page cache plugin

Enable System - Page Cache in System > Plugins. It stores the complete page output for guests, so repeated visits skip most of the PHP work. Options include browser caching headers. Page cache is a major win for blogs and brochure sites, but note:

  • Logged-in users are not served from it.
  • Anything personalized or time-sensitive on a guest page (a random banner, a form with a token) can be stale. Exclude those URLs in the plugin options, or do not cache them.
  • Forms must still work: Joomla's form tokens are handled, but test your contact form and login.
JS Cache TTL and hit ratio

Press Run (or Ctrl + Enter) to see the console output here.

No output.

The stand-in shows the trade-off: a longer time means more hits but older content. For a news site you may choose a few minutes; for a company brochure site, an hour is fine, and you can always clear the cache after an edit.

Browser caching and compression

Static files rarely change, so tell browsers to keep them. On Apache, the .htaccess that Joomla provides contains a commented section for mod_expires and mod_headers you can enable; on nginx you use expires and add_header in the server block. A common policy: images, fonts, CSS and JS for a month or a year, plus versioned file names (Joomla appends a version hash to its own assets so a change busts the cache).

Gzip Page Compression exists in Global Configuration > Server, but compression is better done by the web server (gzip or the newer Brotli), which also compresses CSS, JS, SVG and JSON, not just Joomla's HTML. Turn on only one of them, otherwise the work is done twice.

The saving is large for text. Try it:

JS How much does gzip save?

Press Run (or Ctrl + Enter) to see the console output here.

No output.

Real pages repeat less than this demo, but 70 to 80 percent savings on HTML, CSS and JavaScript are normal. Images are already compressed, so do not gzip them; see Images, Assets and Core Web Vitals.

Other server-side wins

  • PHP version and OPcache: use a supported PHP version and make sure OPcache is on; it removes the cost of compiling PHP files each request.
  • Sessions: the database session handler is fine for small sites; Redis or files reduce database load on busy ones.
  • HTTP/2 or HTTP/3 and HTTPS: faster multiplexing, free through most hosts.
  • Database: periodically Optimize, remove old action logs and expired sessions, and keep extensions that write many rows under control.
  • Debug off: leave Debug System off on production; it adds a lot of overhead.

Troubleshooting stale pages

  1. Hard-refresh the browser (Ctrl+F5) to exclude the browser cache.
  2. System > Clear Cache > Delete All.
  3. Purge the CDN or proxy.
  4. Test while logged out, because page cache only affects guests.
  5. Temporarily switch the cache off to confirm the cache is the cause.

Check your understanding

Quick check ยท 4 questions

of 4 answered You scored / 4 ยท perfect!

  1. 1. Which Joomla feature stores the complete HTML of a page for guests?

    The Page Cache plugin saves whole pages and serves them to visitors who are not logged in.
  2. 2. What is the effect of a very long Cache Time?

    Cached items live longer, so more requests are served from cache, but changes appear later.
  3. 3. Why is a cart module a problem for shared caching?

    User-specific output must not be reused for other visitors.
  4. 4. Why should images not be gzip-compressed?

    JPEG, PNG and WebP are already compressed, so gzip costs CPU for almost no saving.

Summary

  • Cache at several layers: browser, CDN, Joomla page cache, Joomla system cache, server tools.
  • Set the system cache mode, handler and time in Global Configuration; clear it from System > Clear Cache.
  • Use the Page Cache plugin for guest traffic and exclude personalized pages.
  • Compress text on the web server; set long browser caching for versioned static files.
  • Keep PHP and OPcache current and the Debug option off in production.

Next: Images, Assets and Core Web Vitals