Guide WordPress

How to set up caching on WordPress

Page caching turns a rebuilt-every-visit page into a stored copy — how to set it up and avoid caching the parts of a site that must stay live.

Updated 8 min read Intermediate

Every time WordPress serves a page, it normally runs PHP code and queries the database to build that page from scratch, even if the content has not changed since the last visitor saw it. Caching stores a finished copy of the result and serves that copy to the next visitor instead, skipping the rebuild entirely. For most sites, this is the single biggest performance improvement available, because it removes the most expensive part of the request.

The types of caching, and what each one does

TypeWhat it storesEffect
Page cacheA complete, finished HTML pageThe biggest single improvement — skips PHP and the database almost entirely for that page
Object cacheResults of individual database queriesHelps pages that cannot be fully page-cached, such as logged-in areas
Browser cacheStatic files — images, CSS, JavaScript — on the visitor's own deviceNothing to download at all on a repeat visit
CDN cacheCopies of the site held on servers around the worldShortens the physical distance between server and visitor

Page caching gives the largest improvement for the least effort, and it is where to start.

Method 1: enable caching in your control panel

If your control panel offers built-in page caching, this is the simplest option: no plugin to configure, and it runs at server level rather than inside WordPress itself.

  1. Open the caching or performance section of your control panel

    Availability and exact naming depend on your hosting plan.

  2. Turn caching on for the site

    A default configuration is usually sensible to start with.

  3. Test the site while logged in and logged out

    Confirm the admin area still behaves normally and that changes you make while logged in appear correctly rather than showing a stale cached version to yourself.

Method 2: a caching plugin

The more common route, and the one with the most granular control over exactly what gets cached and for how long.

  1. Install a caching plugin

    Any well-maintained, widely used option from the official WordPress plugin directory is a reasonable choice.

  2. Enable page caching

    This is usually the plugin's default and most important setting.

  3. Set a cache expiry period

    How long a cached page is kept before being rebuilt. A day is reasonable for content that rarely changes; shorter for a site that publishes frequently.

  4. Enable browser caching and, if offered, GZIP or Brotli compression

    Both reduce what has to be transferred even on an uncached request.

  5. Configure cache exclusions

    Tell the plugin not to cache your cart, checkout, and account pages if you run a shop — covered below.

What must never be cached

Page caching assumes a page looks the same for every visitor. Anything that is genuinely different per visitor breaks badly if it is cached anyway:

  • Shopping carts and checkout pages. Caching these can show one customer another customer's cart contents. Every caching plugin worth using excludes these by default for a WooCommerce install, but it is worth confirming rather than assuming.
  • Logged-in sessions generally. Most caching plugins automatically skip caching for logged-in users, showing them a live, uncached version instead — this is why an admin can edit content and see changes immediately while visitors still see the cached page until it expires or is cleared.
  • Personalised content such as "welcome back" messages, account dashboards, or anything reading a cookie to decide what to show.
Test as a logged-out visitor, not just as yourself

Because most plugins skip the cache for logged-in users, you can turn caching on, see everything work perfectly as an administrator, and not notice a problem that only shows up for an actual anonymous visitor. Always check in a private browser window with no active login.

Clearing the cache when it matters

A cached page keeps serving its stored version until it expires or is manually cleared, which means a change you make will not be visible to visitors until one of those happens. Every caching plugin provides a manual "clear cache" or "purge" button — use it immediately after any change you need visible right away, such as a price update or a corrected error on a page. Leaving stale content live because nobody remembered to clear the cache is the most common caching complaint, and it is entirely avoidable.

Caching and dynamic content

Page caching works best for content that is genuinely the same for everyone — a blog, a brochure site, a set of static pages. A site with a lot of constantly changing, visitor-specific content needs a different balance, since aggressive full-page caching either has to exclude large parts of the site or risks showing stale personalised data. See caching a site that changes constantly for that situation specifically.

Checking that caching is actually working

Load a page, then view the page source and look for an HTML comment many caching plugins add automatically, confirming the cache served that request along with a timestamp. If your plugin does not add such a marker, compare load times before and after a cache warms up — a second load of the same page should be noticeably faster than the first, uncached one.

For the broader picture of where caching fits alongside the other things that affect speed — images, plugin count, PHP version — see speeding up a WordPress site.

Related reading