Try
↑ ↓ move↵ openesc close
In this lesson · topic 6 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 6

Stale while revalidate and the origin shield

4 min read

Stale while revalidate

When a copy expires, the next user normally waits for the origin. RFC 5861 defines a directive, stale-while-revalidate, that changes this. For a window after expiry the cache may answer with the old copy at once and refresh it in the background.

In the lab the window was 30 ticks. 529 requestsmeasured were answered with an expired copy. Average latency fell from 75 msmeasured to 54 msmeasured. The origin load did not change, because the refresh still happens. What changed is who waits for it. Nobody does.

The trade is a copy that may be a little old for a short time. RFC 5861 also defines stale-if-error, which lets a cache serve an old copy when the origin is failing.

The origin shield

Each edge misses on its own. If 200 edges all miss on a new object, the origin may see 200 requests for it. A shield is one more cache layer that edges ask before they ask the origin. The shield makes one request, and the other 199 are answered by the shield.

With a shield on, the edge hit ratio stayed at 65 percentmeasured. The edges missed just as often. The shield answered 867 of those missesmeasured, so the origin handled 518measured requests instead of 1385measured. Offload rose to 87 percentmeasured.

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