Networking and APIs / Beginner / 5 min / Updated
HTTP caching: Cache-Control, ETag and 304 Not Modified
Switch between no-store, no-cache and max-age, toggle the ETag and watch each visit: served from cache, a tiny 304, a full download or a stale copy.
Start the simulation → Change the load, break a part, watch what happens. Free, no sign-up.
In short
What is HTTP caching?
Cache-Control and ETag headers tell browsers and proxies how long to reuse a response and how to revalidate it.
Why does it matter?
Repeat visits should not download unchanged files; the cheapest request is the one never sent.
What is the trade-off?
max-age skips requests but can show stale content; no-cache plus ETag is always fresh but costs a round trip.
How do you explain it in an interview?
"Fingerprinted assets with max-age one year and immutable; HTML and API GETs with no-cache plus ETag."
Check yourself
What does Cache-Control: no-cache mean?
Answer: Store it, but check with the server before each reuse. no-store forbids storing; no-cache forces revalidation, usually answered with a 304.
What does a 304 Not Modified response contain?
Answer: Headers only: the browser reuses its stored copy. The browser sent If-None-Match with the ETag; the server says the copy is still good.
Why can app.3f9a1c.js safely have max-age of a year?
Answer: Its name changes whenever its content changes, so an old copy is never requested again. Fingerprinted file names make long caching safe; the HTML that references them stays short-lived.