Caching

Why HTTP caching matters

Understand how browser and shared caches reduce repeated downloads, latency, bandwidth use, and work performed by the origin server.

6 minute lesson

~~~

A cache stores a response so it can satisfy a later request without downloading the full body again.

Browsers have private caches for one user. CDNs and proxies can provide shared caches for many users. Your origin server may also cache application work, but HTTP caching specifically concerns reusable responses.

Caching can make a site faster and reduce bandwidth and server load. It can also serve stale or private data when configured badly.

Every cache decision asks two questions:

  1. May this response be stored?
  2. May the stored response be reused now?

Cache-Control answers much of this. Validators such as ETag let a stale cache check whether its stored response still matches the current resource.

Lesson completed