The Plain Picture#
You photocopy a timetable and stick it on your fridge. For a week you trust the copy. After a week you phone the office: "Has the timetable changed since version 12?" — "No." You keep your copy. Only if it changed do they send a new one.
The Real Names#
Cache-Control: max-age=3600— "you may reuse this response for 3,600 seconds without asking."Cache-Control: no-store— "never keep a copy" (for sensitive data).private= only the user's browser may cache it, not shared caches (Ch 12).ETag— a version tag for a response, like"v12"(often a hash of the content).Conditional request — when the copy is too old, the client asks
If-None-Match: "v12". If unchanged, the server replies 304 Not Modified with no body — tiny and fast.
first visit: GET /logo.png → 200 OK, ETag: "v12", max-age=86400, [30 KB image]
within a day: (no request at all — served from the browser's cache)
after a day: GET /logo.png
If-None-Match: "v12" → 304 Not Modified [0 bytes of body]The standard trick for static files: put a hash of the content in the file name (app.3f9a2c.js) and cache it for
a year. When the file changes, its name changes, so browsers fetch the new one. Frontend build tools do this
automatically (JavaScript Modules and Tooling (coming soon)).
Check yourself
3 questionsWhat does max-age=600 mean?
Show answerHide answer
The response may be reused for 600 seconds without contacting the server.
What is an ETag and what does a 304 response mean?
Show answerHide answer
A version identifier for a response; 304 means "your cached version is still current", with no body.
Why put a content hash in a JavaScript file's name?
Show answerHide answer
So it can be cached for a very long time — any change produces a new file name, forcing a fresh download.