System Design · Senior · Question 21 of 75
Why is a Vary: User-Agent or Vary: Cookie header dangerous for a CDN?
- ✓Correct answer: The cache key fragments and almost no hits remain
- 2The CDN stops compressing responses for such requests
- 3The browser rejects responses with that header
Explanation
Vary adds request headers to the cache key. User-Agent and Cookie are nearly unique per visitor, so the cache becomes useless. Normalize the key (device class instead of the full UA) and move personalization out of the cached response.