“Just install a caching plugin” is probably the most common piece of WordPress performance advice. It’s not wrong, but it hides a lot. There isn’t one cache; there are several, at different levels, doing different jobs. Some are handled by your hosting, some by plugins and some by the visitor’s browser.
When clients ask me why their site is slow despite having a caching plugin, the answer is often that one layer is missing, or two layers are fighting each other, or the cache is set up in a way that breaks the shopping cart. Understanding what each layer does makes all of this much easier to diagnose.
So let’s walk through the layers, from the visitor’s browser all the way down to PHP.
Why WordPress needs caching
Without caching, every page request triggers a lot of work. WordPress loads its core files, every active plugin and the theme. It runs dozens or hundreds of database queries to fetch content, settings and menus. It assembles all of that into HTML and sends it back.
On a quiet site with fast hosting, that might take a fraction of a second. Under heavy traffic, or with lots of plugins, it can take several seconds per page and put the server under serious strain.
Caching stores the results of that work so it doesn’t have to be repeated for every visitor.
Layer 1: Browser caching
The visitor’s browser can store files it has already downloaded, such as images, stylesheets, scripts and fonts. When the visitor goes to another page, the browser uses its stored copies instead of downloading them again.
You control this with HTTP headers that tell browsers how long to keep each type of file. Static assets that rarely change can be cached for a long time. On Nginx, for example:
| <code>location ~* .(css | js | jpg | jpeg | png | gif | webp | avif | svg | woff2)$ { |
|---|
What about when you update a stylesheet? WordPress handles this through version numbers in asset URLs, like style.css?ver=1.2. Change the version and browsers download the new file. If you build themes, always version your assets when enqueueing them.
Layer 2: CDN caching
A content delivery network stores copies of your files on servers around the world. A visitor in Australia gets files from a nearby server instead of one in Europe or North America. That reduces latency, the delay caused by physical distance.
Most CDNs cache static assets by default. Some can also cache full HTML pages at the edge, which can make pages load extremely fast globally. That requires careful configuration so that logged-in users, carts and personalised content aren’t cached for everyone.
A CDN also absorbs traffic spikes and can filter malicious traffic, which is a nice bonus.
Layer 3: Page caching
Page caching is what most people mean when they talk about WordPress caching. The first time a page is requested, WordPress builds it normally. The finished HTML is saved. The next visitor receives that saved HTML without WordPress running PHP or database queries at all.
The speed difference is dramatic. A page that took a second to build can be served in milliseconds.
Page caching can happen at different levels:
- Plugin-based, where a WordPress plugin saves HTML files and serves them.
- Server-level, using tools like Nginx FastCGI cache or Varnish, which can serve pages before PHP even starts.
- Host-provided, where managed hosts run their own caching system.
Server-level caching is faster than plugin-based caching, because it skips PHP entirely. If your host provides it, use theirs rather than adding a plugin on top. Two page caches stacked on each other cause confusing problems, like changes not appearing.
What must not be page cached
Page caching works for content that’s the same for everyone. It must not cache content that’s personal. That includes:
- Logged-in users. Most caches bypass the cache when a login cookie is present.
- WooCommerce cart, checkout and my account pages.
- Pages showing personalised data, such as membership dashboards.
- Form submission responses with unique tokens.
WooCommerce sets cookies such as woocommerce_items_in_cart and woocommerce_cart_hash when a visitor adds something to their cart. Good caching setups bypass the cache when those cookies are present. Misconfigured caches can show one customer’s cart to another, which is both a privacy problem and a sales disaster. I’ve seen it happen.
Cache invalidation
When you update a post, the cached version needs to be cleared so visitors see the change. Good caching solutions clear the relevant pages automatically, including the homepage and archives where the post appears. If changes don’t show up, a stale cache is usually the reason.
Layer 4: Object caching
Page caching helps anonymous visitors. But logged-in users, admin pages, carts, checkouts and API requests can’t use it. For those, object caching is what makes the difference.
WordPress has a built-in object cache that stores the results of database queries and other expensive operations in memory. By default, that cache only lasts for a single page load, so the work is repeated on the next request.
A persistent object cache, using Redis or Memcached, keeps that data in memory between requests. The next time WordPress needs the same option or query result, it gets it from memory instead of the database.
The impact is biggest on:
- WooCommerce stores, especially during checkout and in the admin.
- Membership and community sites with many logged-in users.
- Sites with heavy admin usage.
- Sites with slow or overloaded databases.
To use one, your server needs Redis or Memcached installed, and WordPress needs an object cache drop-in, usually provided by a plugin. You can check the connection with WP-CLI:
The second command is available when using the popular Redis object cache plugin.
Layer 5: OPcache
PHP is an interpreted language. Every time a PHP file runs, it’s normally compiled into bytecode first. OPcache stores that compiled bytecode in memory, so PHP files don’t need to be compiled on every request.
OPcache is built into modern PHP and is usually enabled by default on decent hosting. If you manage your own server, check that it’s on and has enough memory for all your sites’ files. A few settings worth reviewing:
If memory is too small for your codebase, OPcache constantly evicts files, and you lose much of the benefit.
Transients: WordPress’s own caching tool
Transients are a WordPress feature that lets developers store data temporarily with an expiry time. A plugin fetching data from an external API might store the result as a transient for an hour, instead of calling the API on every page load.
Without a persistent object cache, transients are stored in the database. With one, they’re stored in memory. Badly written plugins sometimes create huge numbers of transients that never get cleaned up, bloating the options table. That’s a common thing I clean up during performance audits.
How the layers fit together
Picture a visitor requesting a page:
- The browser checks its own cache for assets.
- The CDN checks whether it has a cached copy.
- The server’s page cache checks for saved HTML.
- If nothing is cached, PHP runs, using OPcache for compiled code.
- WordPress checks the object cache before querying the database.
- Only as a last resort does it hit the database.
Each layer catches requests the previous one missed. A well-configured site uses all of them.
Common caching mistakes
- Stacking page caches. Running a plugin page cache on top of a host’s server cache leads to stale pages and confusion.
- Caching personal pages. Not excluding cart, checkout or account pages.
- Minifying and combining everything blindly. Many caching plugins include aggressive script optimization features that break sites. Turn them on one at a time and test.
- Using caching to hide slow code. If uncached pages take five seconds, caching helps visitors but logged-in users and the admin still suffer. Fix the underlying cause.
- Never clearing caches after deployments. Updating a theme without clearing caches can leave visitors with broken layouts.
Frequently asked questions
Do I need a caching plugin if my host has caching?
Often not for page caching. Check what your host provides. You may still want a plugin for specific features, like preloading or asset optimization, but avoid running two page caches together.
Is Redis worth it for a small blog?
For a small blog with mostly anonymous visitors, page caching does most of the work, and Redis adds little. For stores, membership sites or busy admin areas, Redis can make a noticeable difference.
Why don’t my changes show up?
A cache is serving an old version. Clear the page cache, the CDN cache and your browser cache. If it keeps happening, check that automatic cache clearing is working when content is updated.
Can caching break my site?
Page caching itself rarely breaks sites if exclusions are set correctly. Asset optimization features, such as combining or deferring scripts, are the usual culprits. Test each feature separately.
Final thoughts
Caching isn’t one setting; it’s a stack of layers that each solve a different part of the speed problem. Browser and CDN caching speed up static files, page caching speeds up anonymous visits, object caching speeds up everything dynamic and OPcache speeds up PHP itself. Set each layer up deliberately, exclude anything personal and you’ll get a site that’s fast for every visitor, not just the anonymous ones.




