X-Cache
A response header indicating whether the CDN served the content from cache (HIT) or fetched it from origin (MISS). Not standardized, but nearly every CDN uses some variant of it.
Full Explanation
X-Cache is the quickest way to check if the CDN is doing its job. Hit means the edge had a cached copy. Miss means it had to fetch from origin. Some CDNs add more detail: HIT from edge, HIT from shield, MISS, EXPIRED, BYPASS, DYNAMIC.
Different CDNs use different header names. Cloudflare uses CF-Cache-Status. CloudFront uses X-Cache. Fastly uses X-Cache with additional X-Cache-Hits showing the count. Akamai uses X-Cache with TCP_HIT/TCP_MISS values. Varnish uses X-Varnish with two IDs (second ID present means cache hit).
When debugging CDN caching, check X-Cache first. If everything is MISS, look at your Cache-Control headers. If some resources are HIT and others MISS, check the Vary header and cache key configuration. If you see BYPASS, the CDN is intentionally not caching (maybe a cookie or query parameter is triggering it).
Examples
# Check cache status with curl
$ curl -sI https://cdn.example.com/style.css | grep -i 'x-cache\|cf-cache\|age'
X-Cache: HIT
Age: 3247
# Different CDN headers:
# Cloudflare: CF-Cache-Status: HIT
# CloudFront: X-Cache: Hit from cloudfront
# Fastly: X-Cache: HIT, X-Cache-Hits: 42
# Akamai: X-Cache: TCP_HIT from a23.51.224.170
# Varnish: X-Varnish: 12345 67890 (two IDs = HIT)
# Common values:
# HIT - served from cache
# MISS - fetched from origin, now cached
# EXPIRED - TTL expired, revalidating
# BYPASS - not cached by rule
# DYNAMIC - uncacheable content
Frequently Asked Questions
A response header indicating whether the CDN served the content from cache (HIT) or fetched it from origin (MISS). Not standardized, but nearly every CDN uses some variant of it.
# Check cache status with curl
$ curl -sI https://cdn.example.com/style.css | grep -i 'x-cache\|cf-cache\|age'
X-Cache: HIT
Age: 3247
# Different CDN headers:
# Cloudflare: CF-Cache-Status: HIT
# CloudFront: X-Cache: Hit from cloudfront
# Fastly: X-Cache: HIT, X-Cache-Hits: 42
# Akamai: X-Cache: TCP_HIT from a23.51.224.170
# Varnish: X-Varnish: 12345 67890 (two IDs = HIT)
# Common values:
# HIT - served from cache
# MISS - fetched from origin, now cached
# EXPIRED - TTL expired, revalidating
# BYPASS - not cached by rule
# DYNAMIC - uncacheable content
Related CDN concepts include:
- Age Header — A response header added by caches indicating how long (in seconds) the response has been …
- Vary Header — A response header that tells caches which request headers should be included in the cache …
- Cache-Control — The primary HTTP header for controlling caching behavior. Tells browsers, CDNs, and proxies whether to …
- Cache Hit Ratio (CHR) — The percentage of requests served from cache versus total requests. A CHR of 95% means …
- TTL (Time To Live) (TTL) — How long a cached response is considered fresh before it must be revalidated or re-fetched. …