Speeding up WordPress with the page cache

Turn on the page cache for a WordPress site, check that it works, and know when to leave it off.

The page cache keeps a ready-made copy of each public page, so the web server can answer visitors without running WordPress every time. It's off until you turn it on, one site at a time.

Turning it on

  1. Open the domain's WordPress tab.
  2. On the site's card, under Performance, switch on Page cache.

The same switch tells browsers to keep images, CSS, JavaScript and fonts for 30 days, and compresses text files.

Clear cache empties the site's cached pages at once.

Checking that it works

Every page from a cached site carries an X-Hostctl-Cache header. Load the page twice and look at it, in your browser's developer tools or with:

curl -sI https://example.com/ | grep -i x-hostctl-cache
  • MISS: the page wasn't cached yet; it is now.
  • HIT: the page came from the cache.
  • BYPASS: this request is never cached (see below).
  • EXPIRED, STALE or UPDATING: an old copy is being refreshed.

What's never cached

Anyone signed in to WordPress always gets fresh pages, and so do visitors who have left a comment, opened a password-protected post, or put something in a WooCommerce or Easy Digital Downloads cart. So you won't see cached pages while you're signed in; use a private window to check what visitors get.

Also never cached:

  • wp-admin, the sign-in page, the REST API, feeds and sitemaps;
  • cart, checkout and account pages (/cart/, /checkout/, /my-account/, /basket/);
  • any address with a query string (?…), and anything that isn't a plain page view, such as a form being sent.

How soon edits show

A cached page is kept for up to an hour. When you publish or edit a post, moderate a comment, change a menu, widget or the theme, or switch a plugin on or off, Hostctl clears the site's pages within about 30 seconds. Updates, rollbacks and staging pushes made from Hostctl clear it too.

Right after you turn the cache on, the card may say the Hostctl helper is being updated. Until that finishes, press Clear cache after editing.

If you replace an image, CSS or JavaScript file but keep its name, visitors who already have it may see the old one for up to 30 days. Give the new file a new name, or add a version to its address.

When to leave it off

Leave the cache off if the site shows different content to visitors who aren't signed in, on the same address, without a cookie to tell them apart. Some membership, booking, multi-currency and location-based plugins work this way: one visitor's version of the page would be served to everyone.

If something looks wrong after turning the cache on, switch Page cache off. That stops caching for the site straight away.