CDN Cache Key Design That Works
Cache key design determines hit rate. The principles, the pitfalls, and the metrics that prove cache health.
Design principles
Strip query params that do not affect content. Tracking params especially.
Normalize headers: case-insensitive, sorted. Different orderings should not produce different keys.
Pitfalls
Including auth headers in cache key. Cache fragmentation; effectively no caching.
Including user-specific headers. Each user gets their own cache slot.
Metrics
Cache hit rate per route. Below 80% is suspect for static content.
Cache key cardinality. Growing without traffic growing means key design has a leak.