← Home

The Cache Key Is a Privacy Boundary

Aug 4, 2026

A cache is allowed to reuse a response only when the next request is entitled to the same representation. That makes the cache key a privacy boundary, not an implementation footnote.

The classic mistake is a personalized endpoint cached by path alone:

GET /account/summary
cache key: /account/summary

The first authenticated response may now be returned to the next authenticated user. The bug does not require a broken access-control check. It comes from applying correct access control before the cache and then forgetting which identity made the resulting representation valid.

Enumerate representation inputs

Before making a response shareable, list every input that can change it:

If including an input in a shared key is infeasible or unsafe, mark the response private or do not cache it at that layer. Vary: Cookie is not a free solution: it can destroy cache efficiency and still relies on intermediaries honoring the contract. A server-side cache keyed by a stable internal authorization context may be safer than an edge cache trying to infer it from arbitrary headers.

The dangerous optimization

Teams often remove a key dimension after seeing a high cache-cardinality metric. That can be a legitimate performance trade-off for a non-sensitive representation. It is not legitimate when the dropped dimension changes what the requester is allowed to learn.

Write down the intended equivalence class instead: “these two requests may receive the same bytes because they have the same public product page in the same language.” That statement is reviewable. “We cache by URL” is not.

References

Final take

Cache keys partition who may share an answer. Treat changes to them with the same suspicion you would apply to changes in authorization logic.

Changelog