Cache Hit Ratio
Cache hit ratio divides served-from-cache responses by total requests; its definition — bytes versus requests, edge versus shield — must be pinned before it means anything.
Definition
Hit ratio is the fraction of requests answered from cache. Byte hit ratio weights by bytes, capturing bandwidth savings; request hit ratio captures origin offload. Effective hit rate depends on counting location: edge hit, shield hit, or origin. A single number without definitions drives wrong optimization.
Context and scope
Reported by CDNs and application caches as the primary health metric. Trending drops indicate traffic mix changes, cache flushes, or key-space growth.
Common misconceptions
- A high hit ratio means fast pages — hits on tiny objects inflate request ratio while big objects miss and dominate bytes and latency
- Hit ratio above 90 is always good — the right target depends on traffic shape: long-tail APIs and personalized feeds cannot hit like static CDNs
- Hit ratio is a single global number — it varies by route, key class, and region; aggregates hide the segment that regressed
Anti-patterns
- Optimizing request hit ratio while byte misses keep saturating origin egress
- Comparing hit ratios across differently-defined systems and declaring one superior
- Celebrating hit ratio while latency rises because hits are served from an overloaded cache tier
Related concepts
Related examples
Authoritative source
What it is
The ratio answers how often the cache avoids work. But two ratios answer different questions: request ratio measures how many callers avoid the origin; byte ratio measures how much bandwidth the origin avoids. A cache can score well on one and fail the other.
How it works
Counting happens per layer: edge hit, then shield hit, then origin. Optimizations move misses between layers — a shield converts origin fetches into shield hits, raising edge-plus-shield ratios while origin load falls. Segment the metric by route, content class, and region to localize regressions.
When to optimize
Define the target metric by business problem: egress cost wants byte ratio, origin CPU wants request ratio. Track both, plus origin QPS and latency, so a hit-ratio rise cannot mask slower service.
Pitfalls
Tiny hot objects inflate request ratio while the expensive large objects still miss. Personalized or vary-heavy traffic depresses ratios structurally — compare against segment baselines, not cross-system folklore. Cache flushes from deploys create sawtooth artifacts that mislead weekly reports if not annotated.