Browser cache: cache or server?

A page with several objects visited more than once. For each object and each visit, the browser decides: serve it from the cache, revalidate it with a conditional GET, or download it again. Follow the decision tree and the messages it produces.

Page

The first object is the HTML page; the rest are the objects it references. The server sets the freshness of each one with Cache-Control.

max-age in seconds. no-cache: stored but always revalidated. no-store and “none”: never stored.

Visits

Each visit happens t seconds after the previous one. Tick the objects that changed on the server in between.

Examples

Practice

Generates a random page and visits and hides the decisions: for each object of the chosen visit, say what the browser does and what the server answers.

View

Export

Decision tree

Messages of this visit

Cache before and after the visit

Model assumptions
  • Every 200 OK response carries Last-Modified and its explicit freshness: Cache-Control: max-age=N (fresh for N seconds from the moment it was received), no-cache (stored, but always revalidated) or no-store (not stored). A response without freshness information is not stored either.
  • An object that is not in the cache is requested with a normal GET and answered with 200 OK.
  • A fresh copy (age < max-age) is served from the cache without any message.
  • A stale copy (age ≥ max-age, or no-cache) is revalidated with a conditional GET: If-Modified-Since equal to the Last-Modified of the copy. The server answers 304 Not Modified without a body if the object has not changed (the copy becomes fresh again for another max-age), or 200 OK with the new object if it has.
  • The page is one more object: if it is fresh or revalidated with 304, the browser knows the embedded objects from the cached copy. Within a visit the page is handled first and then the objects in order, over a persistent connection without pipelining.
  • Last-Modified is shown symbolically as “L·version”; each change on the server increases the version. Visits are instantaneous: the model says which messages are sent, not how long they take. Out of scope: ETag, heuristic freshness, proxies.