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
- Roy Fielding, Mark Nottingham, Julian Reschke (2022). RFC 9111: HTTP Caching.