Concepts / The web

The web

HTTP cache

Also called caching, Cache-Control, max-age, ETag, If-None-Match, 304 Not Modified

A stored copy of a reply, reused until it expires and then checked with the server.

A fresh copy asks nobody, a stale copy asks once
A fresh copy asks nobody, a stale copy asks once

max-age=3600 keeps a copy fresh for an hour, and during that hour the client sends nothing at all, so the server never hears about those views. After the hour the client asks with the copy's ETag, and 304 Not Modified saves sending the body again. A changed file doesn't reach a client holding a fresh copy, which is why sites put a version in the file's name.

Cache-Control: max-age=3600 says a copy stays good for an hour, and during that time the client doesn't ask at all. After that it sends the copy's ETag in an If-None-Match header, and the server answers 304 Not Modified with no body, or 200 with the new version. no-cache means store it, and check every time.

See it on real machines

Read next

Learn it on real machines.

Every lab is a small network of real Linux machines in your browser. Sign in with Google or email to start.

Start this lab