What is caching? Page, browser, object and CDN caching explained

The different layers of website caching, what each speeds up, and which ones matter most for a site on shared hosting.

ExplainerIntermediate2 min readUpdated

Caching means keeping a ready-made copy of something so it doesn’t have to be produced again. Websites use several layers.

LayerStoresWhereSpeeds up
Page cacheFinished HTML pagesOn the serverServer response (TTFB)
Object cacheResults of database queriesServer memoryDynamic pages and admin
Opcode cacheCompiled PHP codeServer memoryEvery PHP request (handled by the server)
Browser cacheImages, CSS, JSVisitor’s deviceRepeat visits and page-to-page
CDN cacheStatic files, sometimes pagesLocations worldwideDistant visitors

The one that matters most

For WordPress and other dynamic sites on shared hosting, a page cache makes the biggest difference: pages served from cache need almost no PHP or database work, so they’re faster and use far fewer resources. Caching WordPress on shared hosting

Browser caching

Tell browsers to keep static files with cache headers. Hosting static sites and JavaScript framework builds includes an example.

The downside: stale content

Caches can show an old version after you change something.

  • Clear the page cache in your caching plugin after edits
  • Hard-refresh your browser (Ctrl + F5, or Cmd + Shift + R on a Mac)
  • Purge Cloudflare’s cache if you use it

Website showing an old version or the previous host

What shouldn’t be cached

Anything personal: logged-in pages, baskets, checkouts, account areas.

Popular

Tip: press / to search from any pageSee all results