Skip to main content

X-Cache

X-Cache is a non-standard (custom) HTTP response header commonly added by CDNs, reverse proxies, and caching layers to indicate what the cache did with your request. It’s mainly a debugging/observability header: it helps you confirm whether a response was served from cache, forwarded to the origin, or revalidated.

Because X-Cache is not defined by an official RFC, its exact values and meaning vary across providers. Always interpret it in the context of the specific CDN/proxy you are using. Your application controls caching primarily with standard headers such as:

  • Cache-Control
  • ETag
  • Last-Modified
  • Vary
  • Expires

But those headers don’t directly tell you what actually happened in the CDN/proxy. X-Cache is often used to answer questions like:

  • β€œDid the response come from the CDN cache?”
  • β€œWas it a cache miss that went to the origin?”
  • β€œWas the object stale and revalidated?”
  • β€œWhich cache node served it?”

HIT​

The response was served from cache without contacting the origin.

x-cache: Hit from cloudfront

MISS​

The cache did not have a stored response (or could not use it), so it forwarded the request to the origin.

x-cache: Miss from cloudfront

BYPASS​

The cache intentionally skipped caching (e.g., because of cookies, authorization, cache rules, or explicit directives).

EXPIRED / STALE​

The cache had an entry, but it was stale (expired). Depending on rules, it may revalidate or refetch.

REVALIDATED​

The cache checked with the origin (often using ETag / Last-Modified) and could reuse the cached body.