Speed is a feature, and caching is how you pay for it
Site speed isn’t a vanity metric. It moves the numbers you actually care about: faster pages convert better, rank better, and bounce less. Google’s Core Web Vitals bake speed directly into how pages are assessed, and every hundred milliseconds you shave off a page load is measurable money on a store of any size.
The catch is that generating a web page is expensive. On a typical database-driven site — WordPress, WooCommerce, Magento, most CMSes — a single request can mean dozens of database queries, template rendering, plugin logic and API calls, all to produce HTML that is very often identical to what you produced for the last visitor a second ago. Caching is the art of not doing that work twice. Store the result of expensive work and hand it straight back next time.
The confusion most people have is thinking of “cache” as one thing. It isn’t. It’s a stack of caches, each sitting at a different point between your database and your visitor’s eyeballs, each solving a different slice of the problem. Understand the layers and you can reason about speed properly — and, crucially, understand why it all gets complicated the moment you want to run an A/B test.
Let’s walk the layers from the database outwards, then cover the services, the best practices, and the testing problem.
The cache layers, from the server out
A request travels right until a layer can answer it — the earlier that happens, the faster the page. Edge and page caches (highlighted) are the biggest wins because they skip the most work.
1. Opcode cache (PHP OPcache)
The deepest layer, and one you rarely touch directly. Every time PHP runs, it has to compile your source code into bytecode. OPcache stores that compiled bytecode in memory so the compilation happens once, not on every request. On PHP sites it’s essentially free performance and should always be on. Your host almost certainly has it enabled; if not, that’s the first fix.
2. Database query cache and object cache
Your application asks the database the same questions constantly — “what are this product’s details?”, “what’s in the options table?”. An object cache (usually Redis or Memcached) stores the results of those queries and computations in memory, so repeat questions are answered from RAM instead of hammering the database.
This is the single biggest win for logged-in, dynamic and personalised pages that can’t be fully page-cached — think WooCommerce carts, member areas, dashboards. The page still has to be assembled per request, but each assembly is far cheaper because the expensive lookups are already in memory. For any serious WordPress/WooCommerce site, a persistent object cache is close to mandatory.
3. Page cache (full-page HTML cache)
Here’s the big one. Instead of rebuilding the whole HTML document for every visitor, a page cache stores the finished HTML and serves it directly, skipping PHP and the database entirely. A cached page can be served in single-digit milliseconds versus hundreds for an uncached one.
Page caching lives in a few places:
- In the application via a plugin (WP Rocket, LiteSpeed Cache, W3 Total Cache).
- In the web server — Nginx FastCGI cache or Varnish sitting in front of the app.
- At the CDN edge — the fastest option, because the page never even reaches your origin server (more below).
The golden rule of page caching: it’s only safe for content that’s the same for everyone. Product pages, blog posts, category pages, the homepage — great. Anything personalised — cart, checkout, “Hello, Dave”, logged-in views — must be excluded from the page cache or you’ll serve one person’s private page to the next visitor. Getting these exclusions right is most of the work.
4. CDN / edge cache
A Content Delivery Network puts copies of your content in data centres physically close to your users, all around the world. Two distinct jobs:
- Static assets — images, CSS, JS, fonts. These are the easy, universal win: cache them hard at the edge, serve them from a nearby city instead of your origin. Every site should do this.
- Full-page HTML at the edge — the aggressive version, where the CDN caches the whole HTML document and serves it without ever touching your origin. Cloudflare’s APO (Automatic Platform Optimization) for WordPress does exactly this. It’s transformative for speed and for surviving traffic spikes, because most requests never hit your server at all.
5. Browser cache
The last layer, on the visitor’s own device. HTTP caching headers (Cache-Control, ETag, Expires) tell the browser to keep a local copy of your assets so a returning visitor — or one moving between pages — doesn’t re-download your logo, CSS and fonts every time. Set long lifetimes on static assets and use hashed filenames (app.4f3a2b.css) so you can cache them effectively “forever” and still push updates by changing the filename.
Beyond caching: the rest of the speed picture
Caching makes the server fast. But a big chunk of perceived speed is in what you send and how the browser renders it. The high-value non-cache wins:
- Images. Usually the heaviest thing on the page. Serve modern formats (AVIF, then WebP), size them correctly with responsive
srcset, compress them, and lazy-load anything below the fold. This alone often fixes a poor Largest Contentful Paint. - Compression. Serve text assets with Brotli (or gzip) compression. Usually a host/CDN toggle.
- JavaScript discipline. JS is the biggest enemy of interactivity. Defer or async non-critical scripts, minify, code-split, and above all cut third-party tags — each analytics, chat and ad script is someone else’s code blocking your page. This is what drives poor Interaction to Next Paint.
- CSS. Minify, inline critical CSS for above-the-fold content, and defer the rest.
- Fonts. Use
font-display: swap, preload key fonts, self-host where you can to avoid a third-party round trip. - Modern protocols. HTTP/2 and HTTP/3 (QUIC) — again, usually a CDN toggle — remove a lot of connection overhead for free.
- Reserve space for images, ads and embeds to avoid layout shift and protect your Cumulative Layout Shift score.
Measure with real tools, not vibes: Lighthouse / PageSpeed Insights for lab data, WebPageTest for detailed waterfalls, and — most important — CrUX / field data for what real users actually experience. Lab scores are a proxy; the field is the truth.
The best services for each layer
You don’t need all of these, but this is where the value is:
- CDN + edge cache: Cloudflare is the default recommendation — generous free tier, excellent edge cache, APO for WordPress, Cache Rules for fine control, and Workers for edge logic. Alternatives worth knowing: Fastly (superb, very configurable, VCL and edge compute — favoured by large publishers), Bunny.net (cheap, fast, developer-friendly), AWS CloudFront (if you’re already in AWS), Akamai (enterprise).
- WordPress page cache plugins: WP Rocket (the easy, excellent paid default), LiteSpeed Cache (outstanding if your host runs LiteSpeed/OpenLiteSpeed — free and very fast), W3 Total Cache and FlyingPress as strong alternatives.
- Object cache: Redis is the standard; Object Cache Pro is the premium WordPress Redis integration. Memcached is a fine, simpler alternative.
- Image optimisation / CDN: Cloudflare Images and Polish, ShortPixel, Imagify (pairs with WP Rocket), Cloudinary for heavy media workflows.
- Managed hosting with caching built in: Kinsta, WP Engine, Cloudways, and SpinupWP (Nginx FastCGI + Redis) all ship a tuned cache stack so you’re not assembling it yourself.
- Static / JAMstack hosting: Cloudflare Pages, Netlify, Vercel. If your site can be statically generated (this one is — it’s Astro on Cloudflare Pages), you sidestep most of the caching problem entirely: there’s no database to be slow, and the whole site lives on the edge as static files.
A pragmatic default stack for a typical WooCommerce store: quality managed host + Redis object cache + a page cache plugin + Cloudflare in front (with APO) + an image optimiser. That combination handles 95% of the speed problem.
Best practices that separate fast sites from fragile ones
- Cache the cacheable, exclude the personal. Cart, checkout, my-account, and any logged-in or personalised view must bypass the full-page cache. This is the number-one cause of “why is another customer’s basket showing on my site” incidents.
- Get your cache keys right. The cache key decides what counts as “the same page”. If you serve different content by device, currency or country, your cache must vary on that dimension — or you’ll serve the desktop page to mobile, or GBP prices to a US visitor. (Hold that thought — it’s exactly the mechanism that makes A/B testing possible under a cache.)
- Have a real invalidation strategy. “There are only two hard things in computer science: cache invalidation and naming things.” When a product price changes, the cached page must be purged. Automate purging on content updates, and understand your tool’s purge scope (one URL vs everything).
- Use
stale-while-revalidate. Serve the slightly-stale cached copy instantly while fetching a fresh one in the background. Users get speed; you get freshness. Best of both. - Set aggressive TTLs on immutable assets, short ones on HTML. Hashed static assets can cache for a year; HTML should be short-lived or purge-driven so content updates appear promptly.
- Watch your cache hit ratio. A page cache with a 40% hit rate is barely working. Most requests should be served from cache; if they’re not, something (a rogue cookie, a cache-busting query string, an over-broad exclusion) is poisoning it.
- Don’t let third-party scripts undo it all. You can cache your HTML to perfection and still ship a two-second page because of five marketing tags. Speed is a whole-page property.
And now the awkward part: caching versus A/B testing
Here’s the tension that catches teams out, and it’s fundamental, not incidental. A cache exists to serve one identical response to everybody. An A/B test exists to serve different responses to different people. Those two goals are in direct opposition, and if you don’t reconcile them deliberately, one silently breaks the other.
The classic failure is brutal in its simplicity. You’ve got full-page caching on (as you should). You launch an A/B test that changes the hero on your homepage. The first visitor after the cache clears gets bucketed into — say — the variant, the variant HTML is generated, and that variant HTML is now the cached copy served to everyone else, regardless of which bucket they’re assigned to. Your carefully-designed 50/50 split collapses to 100/0. The test looks like it’s running; the dashboard fills with data; the data is meaningless, because everyone saw the same thing.
There are only a few honest ways out, and each is a trade-off:
- Bypass the cache on tested pages. Simple, and it works — but you’ve thrown away the performance on exactly the pages you’re trying to optimise, and a slow variant will now lose for reasons that have nothing to do with the change. Rarely the right answer.
- Client-side testing. Let the page cache normally, then rewrite it in the browser with JavaScript after load. This is what most testing tools do — and it reintroduces the flicker, the speed tax and the sample contamination I’ve written about in edge vs client-side A/B testing. You’ve solved the cache problem by moving it onto the user’s device, at a cost.
- Make the cache variant-aware. The proper fix. You fold the visitor’s test assignment into the cache key — the same mechanism you’d use to vary cache by device or currency. Each variant caches independently, and each visitor gets a fast, cached response for their own bucket. You keep full-page performance and a clean experiment. This is fiddly enough to deserve its own walkthrough, which is exactly what caching server-side A/B tests on Cloudflare covers in detail.
Doing that variant-aware caching at the edge — bucketing the visitor and serving the right cached variant from the CDN, before the request ever reaches your origin — is the cleanest answer of all, because you lose neither speed nor validity. It’s the whole reason edge experimentation exists.
A single cached page is served to everyone, so the split collapses. Folding each visitor's bucket into the cache key lets both variants cache independently — full-page speed and a clean experiment.
One real-world wrinkle worth flagging, because it bit us on radio-controlled.co.uk: aggressive edge page-caching and custom edge logic can fight each other. Cloudflare’s APO (full-page WordPress caching) stacked underneath a custom Worker doing A/B assignment produced intermittent origin errors under real traffic — the two were competing over the same origin-fetch path. The lesson isn’t “don’t do edge testing”; it’s that your caching layer and your experimentation layer have to be designed together, as one system. When they’re bolted on independently, they collide — either the cache breaks the test, or the test breaks the cache, or (worst) they intermittently break each other in ways that are miserable to debug.
The takeaway
Fast sites aren’t magic; they’re a well-managed stack of caches — opcode, object, page, edge, browser — each doing its job, with clean exclusions and a real invalidation strategy, sitting behind a good CDN and in front of lean, well-optimised front-end code. Pick sensible services for each layer, measure with field data, and most of the speed problem is solved.
Just go in with your eyes open about experimentation. The moment you want to test, “serve everyone the same fast page” stops being the whole goal — and you have to design a system that can be both fast and different-per-visitor at once. That’s a solvable problem, but only if you treat caching and testing as one design, not two features that happen to share a website.
Reconciling those two goals — full-edge caching and clean, per-visitor experiments — is precisely what Conversion Workers is built to do: variant assignment and variant-aware caching handled together at the Cloudflare edge, so your tests don’t collapse your cache and your cache doesn’t collapse your tests. If your experiments and your performance work keep tripping over each other, that’s the layer to look at.