How it works
Caches sit at every layer. The browser keeps images, scripts and pages according to the Cache-Control header; a CDN keeps copies in data centres near visitors; the server caches rendered pages or API results; and a store such as Redis holds the results of slow database queries. Each hit saves time, bandwidth and money.
The hard part is freshness. Lifetimes (max-age), revalidation (an ETag and a 304 'not modified' reply) and fingerprinted file names such as app.3f9a1c.js let files be cached for a year yet replaced the moment they change. Anything personal, such as a basket or an account page, must be marked private or no-store, or a shared cache could show one visitor's data to another.
Related terms
More in How the web works
Requests and responses