Speeding up display
Serving a ready copy is almost always faster than rebuilding the response, especially on a mobile connection.
A cache is temporary storage that keeps the result of an expensive operation so it can be reused instead of recomputed. On the web it avoids asking the server again for an image, a page or a piece of data already fetched, cutting both display time and machine load.
In one sentence
A cache keeps a copy of what has already been computed, so it need not be done again.
Key points
Term at a glance
The principle is old and reaches well beyond the web: when an operation is slow or expensive, you keep its result to hand. The second request no longer pays the price the first one did. What varies between caches is where the copy is kept and how long it is treated as trustworthy.
On a website several caches sit on top of each other. The browser keeps images and files already downloaded. A delivery network keeps a copy of pages on servers close to the visitor. The application server keeps the result of repeated computations. The database keeps frequent queries in memory.
The real difficulty is not caching: it is invalidation. How long does a copy stay correct? What happens when the underlying data changes? A price updated in your back office but served from a cache for six hours is a commercial problem, not a technical footnote.
The system first checks whether it already holds a valid copy of what is being asked for.
It is returned immediately, with no recomputation and no database call. This is the fast path.
The operation runs normally, and its result is stored for subsequent requests.
The copy must be invalidated, either when a set delay expires or explicitly at the moment of the change.
Your home page shows your three latest articles. Without a cache, every visitor triggers a database query to find them — a thousand visitors, a thousand identical queries. With a five-minute cache, the first visit pays the cost and the rest receive the copy. The database goes from a thousand queries to twelve an hour, and the page loads faster for everyone.
Serving a ready copy is almost always faster than rebuilding the response, especially on a mobile connection.
Fewer computations and fewer database queries mean smaller machines for the same traffic.
During a campaign or a traffic peak, the cache takes load the server could not handle.
Some caches keep serving a copy even while the origin service is briefly unavailable.
It is the performance lever with the best effort-to-result ratio. Correct caching often buys more seconds than a full redesign, for a fraction of the cost. The flip side is that a badly tuned cache shows stale prices, stock levels or opening hours — and that mistake is visible to customers.
Because a cache is still serving the old version. Depending on the level involved, you either wait for the delay to expire or trigger an explicit invalidation after the change.
No. Personalised pages, baskets and sensitive data should not be, or only privately in the visitor's own browser. A shared cache holding personal data is a leak.
It depends how often the data changes and what a stale version costs. A few minutes for an article list; a year for an image whose filename changes with every version.
Site still slow despite decent hosting? Caching is usually the first lever to pull, and the cheapest.
Have your performance measured