CDN Cache Keys and the Vary Header

A cache key decides whether two requests may reuse the same stored response. A typical CDN starts with the request scheme, host, path, and query string. It may also include selected headers or cookies. The Vary response header is the HTTP mechanism that tells a cache which request headers selected a representation. The safe goal is simple: requests that should receive the same bytes should share a key, while requests that require different bytes must not collide. A key that is too narrow can expose the wrong response. A key that is too broad creates many variants, lowers the cache hit ratio , and increases origin traffic. ...

August 13, 2026 · CDN Handbook

Cache-Control & TTLs: Getting Caching Right

Caching is one of the simplest ways to improve delivery. A cache saves a copy of a response so it can be served without a round trip to the origin . The core control surface is the Cache-Control header and the time-to-live (TTL ). Freshness and validation determine when a cache can reuse a stored response and when it must contact the origin. Quick answers max-age sets freshness for private and shared caches. s-maxage overrides max-age in a shared cache such as a CDN. It does not change the browser’s freshness lifetime. Vary tells a cache which request headers selected the response. Each meaningful value can create a separate representation. Vary: * prevents normal reuse because the cache cannot prove that a later request is equivalent. no-cache allows storage but requires validation before reuse. no-store prohibits storage. Freshness vs validation A cache serves a response when it is fresh. Freshness comes from an explicit lifetime such as max-age or from an older Expires date. After freshness ends, a cache either revalidates or fetches again. ...

August 15, 2025 · CDN Handbook