Try
↑ ↓ move↵ openesc close
In this lesson · topic 2 of 7
  1. 1. One origin, every user
  2. 2. Hit, miss and the TTL
  3. 3. Move the TTL and watch the origin
  4. 4. A noisy key, a cold edge, a stale page
  5. 5. Cache keys and purging
  6. 6. Stale while revalidate and the origin shield
  7. 7. Edge caches in review

Topic 2

Hit, miss and the TTL

4 min read

The path of a request

A request reaches the nearest edge. The edge looks up a key built from the request, usually the host and path. There are two cases.

  • Hit. The edge holds a copy that is still fresh. It answers at once.
  • Miss. The edge has no copy, or the copy is too old. It asks the origin, stores the reply, and answers the user. The next request for that key is a hit.

The server tells caches how long a copy is fresh. The HTTP caching standard, RFC 9111, defines the rules. The usual signal is Cache-Control: max-age=60, which says the copy may be reused for 60 seconds. This length is the time to live, or TTL.

What the TTL trades

A longer TTL means a copy serves more requests before it expires, so the hit ratio rises and the origin sees less. It also means a copy can outlive a change at the origin.

In the lab the TTL was 10, 60 and 300 ticks, with everything else equal. The hit ratio went from 36 percentmeasured to 65 percentmeasured to 85 percentmeasured. Origin requests fell from 2571measured to 1385measured to 591measured.

The price shows in the stale share, the part of responses older than the current version. In the run it was 4 percentmeasured at a TTL of 10 and 40 percentmeasured at 300. In this model one object changes about every five ticks. Real sites change far less often, and so the staleness is smaller. The direction is the same.

Your progress is saved in this browser. Sign in to keep it on every device. Privacy · Terms