Page caching on WordPress, explained without the jargon
Why WordPress builds every page from scratch, how a page cache removes most of that work, and the three situations where caching goes wrong.
Every time someone opens a page on a normal WordPress site, the server does the whole job again: it loads WordPress, every active plugin and the theme, asks the database dozens of questions, and assembles the HTML. For a page that has not changed since yesterday, that is a lot of repeated work.
A page cache keeps the finished HTML and hands it out until something changes. On most sites it is the single biggest speed improvement available, and it costs nothing.
Where the time goes
The part of loading a page that the server controls shows up as Time to First Byte (TTFB): how long the browser waits before the first byte of the page arrives. web.dev suggests aiming for about 0.8 seconds or less as a rough guide. Uncached WordPress pages on shared hosting often take several hundred milliseconds to well over a second, before the browser has even started on images and scripts.
A cached page skips WordPress entirely. The server reads a file and sends it, usually in a few milliseconds. Everything that happens afterwards, fonts, images, scripts, starts that much earlier.
What gets cached, and what must not
A page cache stores copies of pages as anonymous visitors see them. It must not cache:
- Anything for logged-in people. Their pages contain their name, their admin bar and their nonces.
- Carts, checkout and account pages. Every visitor's cart is different.
- Pages that change per visitor, such as currency switchers or membership content, unless the cache knows how to keep separate copies.
Good caching plugins exclude the obvious cases automatically and let you add the rest.
When caching goes wrong
Stale content. The cache needs to know when to throw a copy away. Editing a post should clear that post, the home page, the blog page and the archives it appears in. The tricky case is content that changes outside WordPress, such as prices synced from a point-of-sale system or stock from a warehouse. WordPress never hears about those changes, so pages also need a maximum age.
Two caches fighting. Hosting companies often add their own server cache, and Cloudflare can cache HTML too. Three layers that do not talk to each other produce pages that refuse to update. Pick one HTML cache and make sure clearing it also clears the CDN.
Cold caches. Right after a clear, the first visitor to each page pays the full price. Rebuilding popular pages in the background, slowly, avoids that.
A five-minute check
- Open a page in a private window and look at the response headers in the browser's network panel. Many caches add a header such as
x-cacheor a comment at the bottom of the HTML. - Reload and compare the time to first byte. A cached page should be dramatically faster.
- Edit the page, reload as a visitor, and confirm the change appears straight away.
In Ironhelm
The page cache serves ready-made copies of pages, never caches logged-in people, carts, checkout or account pages, and clears the right pages the moment you edit something. A maximum age catches changes made outside WordPress, the cache can rebuild pages in the background after a clear, and Cloudflare is cleared automatically when you connect it.
Sources
- web.dev, Time to First Byte (TTFB)
- web.dev, Optimize Time to First Byte
- MDN Web Docs, HTTP caching
Ironhelm Suite is one WordPress plugin for security, speed, SEO and analytics. See plans or tour the features.