Skip to content
Getting Digital

Caching

Also: cache, HTTP caching, page cache

Caching keeps the result of expensive work, such as a rendered page or a database query, and serves that stored copy until it expires, making it the largest single source of speed on any busy website.

Our take. Install a full-page cache before you install anything else, and treat an object cache in Redis as a second step you take after measuring rather than a box to tick on day one. A cache with no automatic purge when an editor hits publish is not an incomplete setup, it is a defect, and it will reach you worded as the site is broken.

Do the work once, answer many times

A request that arrives twice should only be expensive once, and every layer between a visitor and your database exists to make that true. The browser holds assets it was told it may keep, under instructions carried in the Cache-Control header. An edge network such as Cloudflare or Fastly holds copies in data centres near the visitor. On the origin, full-page caching built into nginx or sitting in front of it in Varnish returns finished HTML without ever waking PHP. Behind that, an object cache in Redis or Memcached stores query results and rendered fragments so the application stops asking Postgres or MySQL the same question all day. Each layer that answers leaves every layer behind it idle, which is why a properly cached site on modest shared hosting will outrun an uncached one on far larger hardware. The boundary of all this is personalisation. Anything that differs per visitor, a basket, a name in the corner, a price after a customer discount, has to be excluded or handled with care, and the header that announces it is Cache-Control with the value private. Everything else is fair game, and on most sites everything else is the overwhelming majority of what gets requested.

What goes wrong is almost never the storing. It is the forgetting. A cached answer is a standing claim that nothing has changed, and each layer needs its own story for the moment that claim stops being true. Three tools cover nearly all of it: a time-to-live sized to how much staleness the content can tolerate, an explicit purge fired when something is published, and versioned filenames for assets, which sidestep the problem entirely because a changed file is simply a different address. Skip the purge and you generate the support ticket every host receives daily, the one that begins with an editor saying they updated a page and nothing happened. Diagnose those from the visitor inwards, because the layers fail in a predictable order: a hard reload clears the browser, the edge is the next suspect, and the origin page cache is usually the guilty party on a CMS whose plugin never learned about a custom publishing workflow. The quieter failure is worse. Store a response that was built for one signed-in person in a cache that several people share, and you will hand somebody else's account page to a stranger. That is why sensible configurations keep authenticated routes out of shared caches by rule rather than by hope.

In practice

Open the network tab on a site built with any modern bundler and you will see filenames in the shape of app.4f2c1a9.js. The hash is derived from the contents, so changing the code produces a different name and therefore a different address. That is what makes the aggressive instruction safe: Cache-Control with public, max-age=31536000, immutable, where the number is nothing more exotic than 365 x 24 x 60 x 60, a year counted in seconds. The HTML pointing at those files gets the opposite treatment, a short lifetime or none at all, because the document has to change first before anyone can discover the new asset names. Reverse that pairing, with long-lived HTML and short-lived assets, and every deployment strands visitors on an old page requesting files that no longer exist.

Often confused with

CDN (Content Delivery Network)
A CDN is somewhere a cache lives, not an alternative to having one; the rules you set at your origin are what its edge locations obey.

Key takeaways

  • →Browser, edge, page and object caches each absorb requests before the expensive work behind them starts, so the benefit compounds down the stack.
  • →Expiry, purge-on-publish and hashed filenames are the whole practical toolkit for keeping stored answers honest.
  • →The dangerous bug is not staleness; it is a per-visitor response stored somewhere several visitors can reach.

Related concepts

Certifications that test this

Vendor exams whose syllabus covers this concept — facts, cost and a preparation path on each page.

More courses from these shelves

A rotating selection from the course directory, drawn from the subcategories where this concept is taught rather than picked for it. Details, price and the provider link are on the course page.

Introduction to Cloud Data Analytics with Google BigQuery

This course is designed for the students who are at their initial stage or at the beginner level in learning the data w…

Udemy

Begin with Microservices

In this course, you will learn how to build REST APIs or Microservices using the latest version of Spring Boot), and Mo…

Udemy

AWS EKS (Elastic Kubernetes Service)

The Course is divided into 3 parts -Part 1 - Kubernetes and its objects (Deep Dive). In this part I will talk about Kub…

Udemy

Increasing BDD Code Efficiency

Increasing BDD (Behavior Driven Development) Code Efficiency is all about minimizing your maintenance effort while maxi…

Udemy

Azure Kubernetes Service AGIC Ingress: 30 Real-World Demos

Course Overview Welcome to this Amazing course on Azure Kubernetes Service AGIC Ingress: 30 Real-World Demos. Below is…

Udemy

Monitoring and Maintaining Agent Performance

Are you building, deploying, or managing AI agents and want to ensure they operate at peak performance? Monitoring and…

Udemy

FAQ

I published a change and the site still shows the old version.
Something between you and the origin is still handing out its stored copy. Reload with the browser cache bypassed to rule out your own machine, then purge the edge, then purge the site's page cache. If this happens on every single update, the setup is missing a purge hook rather than suffering an occasional glitch.
Do I need Redis if I already have page caching?
Often not. A page cache answers anonymous traffic without touching the application at all, which is the bulk of the win for a content site. An object cache earns its place where the application genuinely has to run, so signed-in dashboards, shops with per-customer pricing and busy APIs benefit, while a brochure site rarely notices.
How long should a time-to-live be?
Long enough to be useful, short enough that an accidental miss of a purge is survivable. Assets with hashed names can be kept for a year because their address changes when they do. Documents are usually measured in minutes, with revalidation so the stored copy can still be served while a fresh one is fetched.

Sources

The primary text this definition rests on. Read it before you trust ours.

Last reviewed 14 September 2026 · Getting Digital