Try
↑ ↓ move↵ openesc close

Interview prep / CDNs and edge caching

Mid · CDNs and edge caching · System design interview question

What is a cache key, and how can a bad one hurt a CDN?

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

A strong answer

The key is what a cache uses to decide two requests want the same object. It is usually the host and path, plus any request headers the response depends on, which a server names with the Vary header.

A key that includes a value that changes per request, such as a tracking parameter, turns one object into many entries. Each needs its own miss. The hit ratio falls and origin load rises, while users ask for the same things.

The fix is to list the parameters and headers that matter and ignore the rest. Add a Vary header only when the body really differs, since each one multiplies the entries.

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