Try
↑ ↓ move↵ openesc close

Interview prep / CDNs and edge caching

Mid · CDNs and edge caching · System design interview question

What does stale-while-revalidate do, and what does it cost?

Sketch your own answer first, then compare it with the one below.

A strong answer

It lets a cache answer with an expired copy for a short window after expiry, while it refreshes the copy in the background. Users do not wait for the origin on the request that finds the copy expired.

The cost is that a user may see a copy that is slightly old. The origin load does not fall, because the refresh still happens. What changes is who waits for it.

A related directive, stale-if-error, lets a cache serve an old copy when the origin is failing, which keeps a site up through a short outage.

Sources

Learn it by running it

The cdns and edge caching lesson explains the mechanism behind this question, and its lab lets you change the parameters and watch the effect.

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