ContentsThe library

From an Address to a Page

The Fastest Request Is the One That Is Never Sent, and Whether It Is Sent Was Decided by a Line of Text Last Week

Last timeThe Request and the Answer

Caching is not lore. Four headers and three questions decide, for any resource, whether a second visit sends nothing, sends a short question, or fetches the whole thing again.

Fresh or stale

A cache is a store of previous responses, and the only question it ever asks is

whether the stored copy may be used. That question has a precise answer derived

from two numbers.

FIG 1Freshness remaining
the freshness remaining, in seconds; while it is positive the copy may be used with no request
the lifetime the server stated when it sent the copy
the age of the copy, counted from when the server generated it rather than when this cache received it
The age is counted from generation, not from receipt, which matters because a copy may have sat in a shared cache for a while before reaching yours. That is why responses from a content network carry an age field: it tells the next cache down how much of the lifetime has already been spent.

While the remaining freshness is positive, nothing happens on the network. The

browser takes the copy out of its own store and renders it. No lookup, no

connection, no round trip, no server involvement whatsoever. This is the only

mechanism in the entire course that makes a request cost zero.

Asking only whether it changed

When the copy goes stale, the natural assumption is that it must be fetched

again. It does not.

A stale copy still carries the tag the server attached to it. Sending that tag

back turns the request into a question: do you still have this exact version.

If the answer is yes, the response is a status line and a few headers with no

body at all.

The lesson stops here

4 more paragraphs to go

You have read the opening. The rest of the argument, the problems that check whether it landed, and the lines worth keeping at the end all come with a plan.

The first lesson of every course in the library reads the whole way through, free, so you can see exactly what the rest of them are.

See the planThe contents

This is the reading half

Starting the course gives you your own copy of it. Every idea on every page has problems standing under it, marked with a reason rather than a tick, and any sentence you do not believe can be opened and argued with. None of that can happen on a page nobody owns.

The contents

The rest of this course

  1. 01Before Anything Can Be Sent, Something Has to Find Out Where to Send It, and Usually That Costs Nothing
  2. 02Four Round Trips Before the First Useful Byte, and Every One of Them Is the Speed of Light Doing Its Jobopening only
  3. 03The Network Will Lose Some of Your Packets and Tell Nobody, So Everything Above It Is Built on Noticingopening only
  4. 04Your Connection Is a Hundred Megabits and the First Thing It Sends Is Fourteen Kilobytes, on Purposeopening only
  5. 05After Four Round Trips of Machinery, What Finally Goes Down the Wire Is a Few Lines of Text You Could Have Typedopening only
  6. 06The Fastest Request Is the One That Is Never Sent, and Whether It Is Sent Was Decided by a Line of Text Last Weekyou are here
  7. 07You Think You Are Talking to a Server, and You Are Talking to Four Machines That Have Agreed Not to Mention Itopening only
  8. 08The Page Took Two and a Half Seconds, and Four Hundred Milliseconds of That Was Your Codeopening only

Read alongside