What is a cache hit and a cache miss?
A hit is a request answered from cache. A miss is one the cache had to forward to the origin because it had no usable stored copy.
A cache hit is a request that the cache answers with a stored response, without contacting the origin. A cache miss is a request the cache cannot answer from storage, because it has no copy or its copy is stale, so it forwards the request to the origin. Hits are fast and cheap. Misses cost an origin round trip.
cf-cache-status: HIT
x-cache: MISS
x-vercel-cache: HIT
Cache-Status: ExampleCache; fwd=uri-missBetween the two sit states each CDN names differently. Cloudflare's CF-Cache-Status, for example, has:
HITandMISS, andEXPIRED: found in cache but expired, and served from the origin.STALE: served from cache although expired, because the origin could not be reached.UPDATING: served stale while a refresh runs.REVALIDATED: a stale copy was checked with the origin and served from cache.BYPASSandDYNAMIC: not eligible for caching, so not a miss in the usual sense.
A `Cache-Status` header normalizes this across caches. The share of hits is the cache hit ratio, and a cold cache is one where every request is a miss.
Related terms
References
- Cloudflare: Cache responseshttps://developers.cloudflare.com/cache/concepts/cache-responses/
- Fastly: X-Cachehttps://www.fastly.com/documentation/reference/http/http-headers/X-Cache/
- RFC 9211: The Cache-Status HTTP Response Header Fieldhttps://www.rfc-editor.org/rfc/rfc9211
Warm your cache after every deploy
sitewarm requests the pages in your sitemap after a deploy and reports the cache state the CDN returns for each one, with the vantage point it was measured from.