Skip to content

WordPress Caching Explained: Layers, Setup and Pitfalls

This page contains affiliate links. If you choose to make a purchase through these links, I may earn a small commission at no extra cost to you.

Isometric wordpress caching layers showing a page request moving through cache, server and database

Quick Answer

WordPress caching stores reusable work so a page can be delivered without rebuilding every database query, PHP operation and asset transfer for every visit. A practical setup usually combines page caching, browser caching and server-level object or opcode caching, with a clear purge strategy.

Start with the cache layer supplied by your host or CDN. Add a plugin only when it solves a specific missing job, and avoid running two page-cache systems against the same pages.

What WordPress caching actually does

A normal uncached request can involve the web server, PHP, WordPress, the database, the active theme and several plugins before HTML reaches the visitor. Caching saves the result, or saves expensive intermediate results, so later requests can skip part of that work.

There is no single WordPress cache. The useful mental model is a stack of layers. Page cache stores complete responses. Browser cache lets a visitor reuse files already downloaded. Object cache stores database-derived objects. Opcode cache retains compiled PHP instructions. A CDN may cache pages or assets at locations closer to visitors.

WordPress cache layersA request moves from browser and CDN caches to page cache, then PHP and object cache, before reaching the database.Browserasset cacheCDNedge cachePage cachesaved HTMLPHPopcode cacheObjectsRedis or MemcachedDatabase
The fastest request is often the one answered by an earlier layer. A miss moves deeper into wordpress.

The main cache layers

Page caching

Page caching saves the complete HTML response for an eligible URL. It usually delivers the largest improvement for public articles and landing pages because WordPress does not need to rebuild the page on every view. Logged-in dashboards, carts, checkouts and personalised pages normally need exclusions or variation rules.

Browser caching

Cache-control and expiry headers tell the visitor’s browser how long it may reuse images, stylesheets, scripts and fonts. Long lifetimes work well for versioned static files. HTML needs a more cautious policy because it changes more often.

Object and database caching

WordPress has an object-cache API, but its default cache does not persist between requests. A persistent drop-in backed by Redis or Memcached can reuse query results and objects across requests. This helps database-heavy sites, but it does not replace page caching.

Opcode and server caching

PHP OPcache stores compiled bytecode so PHP files do not have to be parsed repeatedly. Hosts may also provide FastCGI cache, Varnish or a proprietary page cache. These layers are often more efficient than a plugin because they operate closer to the server.

Wordpress official caching documentation
Wordpress documents page, browser, object and server caching as distinct layers. Source: wordpress developer resources.

What WP_CACHE means

The WP_CACHE constant signals that WordPress may load caching code early in the request. It does not, by itself, configure browser headers, create a Redis service or guarantee that page caching is active. A plugin or host integration still has to provide the relevant cache implementation.

Likewise, seeing an object-cache.php drop-in means a persistent object-cache integration may be present, but the backend service, connection and eviction behaviour still need to be checked.

Wordpress official documentation describing cache layers and configuration
The configuration constant and cache drop-ins are parts of a wider stack, not a complete performance strategy. Source: wordpress developer resources.

A safe setup order

  1. Measure first. Record representative public and logged-in pages, server response time and uncached behaviour.
  2. Inventory existing layers. Ask the host which page, object, opcode and CDN caches are already active.
  3. Choose one page-cache owner. Avoid overlapping full-page cache plugins unless the documented architecture requires it.
  4. Define exclusions. Protect carts, checkouts, account areas, previews, feeds and personalised responses.
  5. Set asset lifetimes. Use versioned filenames so long browser-cache periods do not leave visitors with stale CSS or JavaScript.
  6. Test purge paths. Publishing, editing menus, changing widgets and deploying code should invalidate the correct cached pages.
  7. Re-measure. Test both cache misses and hits, plus mobile and authenticated workflows.

Common caching problems

Visitors see old content

A purge may clear only one layer. The WordPress plugin, host cache, CDN and browser can each retain a different copy. Purge from the narrowest affected layer first, then confirm response headers and the final HTML.

Checkout or account data leaks

Full-page cache must not serve one user’s personalised response to another. Exclude session-sensitive routes and cookies according to the ecommerce or membership plugin’s current guidance.

The site is fast only for repeat visitors

That often means browser caching is working while the origin still builds slow HTML. Test a clean first request and inspect server timing separately from asset reuse.

Too many optimisation plugins

Minification, defer rules, image processing and page caching are different jobs. Combining several plugins that each modify all four creates difficult interactions. Assign one owner to each job and document it.

How to choose a caching plugin

Start with compatibility, not the longest feature list. A plugin should understand the hosting environment, support the site’s commerce or membership exclusions, provide predictable purges and expose enough information to troubleshoot. If the host already provides full-page caching, a lighter plugin for asset optimisation may be the better choice.

Managed hosts often integrate cache invalidation with WordPress publishing events. On a self-managed server, a plugin may be the practical control layer. Neither approach removes the need for staging, backups and change monitoring.

Next steps

Document the active cache layers, identify the one responsible for full pages, list the routes that must never be shared, and test a complete publish-to-purge cycle. Only then add another optimisation layer.

Frequently asked questions

Does WordPress include caching?

WordPress includes an object-cache API and supports cache drop-ins, but a complete persistent or full-page cache depends on the host, plugin or server configuration.

Should I use two caching plugins?

Usually no. Assign one system to full-page caching. A separate plugin can handle a different job, but overlapping ownership makes purges and exclusions harder to reason about.

Does clearing cache improve speed?

Clearing cache can fix stale output, but the next request is a cache miss and may be slower. Regularly clearing every layer is not a performance strategy.

Is Redis the same as page caching?

No. Redis is commonly used for persistent object caching. Page caching stores complete responses and usually has a different role.

Sources and image credits

Share this article

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *

Contents