Caching & Revalidation
Run curl -v https://example.com/logo.png twice and the first prints a full image behind a screenful of headers. The second can come back before the request ever reaches the server, or with an empty body: same command, very different cost.
- ▸The fastest response never leaves: while a copy is fresh, your cache answers and the server never hears it.
- ▸
no-cachestill caches; it only refuses to reuse a copy without checking first.no-storeis what prevents storage. - ▸A
304is a repeat request's win: same round trip, zero body bytes, because you already hold them.
The second curl comes back almost instantly, and the origin's access log stays empty: it never saw the request. The first response arrived carrying Cache-Control: max-age=60, and your cache read that as a *freshness lifetime*, a window during which it may answer from its stored copy without asking anyone. Inside that window every repeat request is served locally. The fastest response is the one that never leaves your machine.
The subtle part is where the clock starts. max-age counts from the moment the origin *generated* the response, not the moment you received it. A response that spent time in an intermediary arrives with an Age already on the meter, so a copy handed to you with Age: 50 and max-age=60 is fresh for only ten more seconds. Push the age past the lifetime and the copy goes *stale*: your cache may no longer hand it out blindly.