Hit ratio — the headline and the diagnostic ladder
Hit ratio is the one number that tells you whether the CDN is earning its money — request hit ratio for users, byte hit ratio for the bandwidth bill — and when it's low the diagnostic ladder is Vary cardinality → TTL config → purge frequency → bypass rules → cookie cache key.
Every lever we've built — TTL, Vary, purge, shield, bypass — moves one number, origin RPS, and the headline that summarizes them all is hit ratio; this is the dashboard you read, and the ladder you walk when it's low.
Scene 11
Hit ratio — the headline and the diagnostic ladder
- Watch
- Try it
- Predict
- Capture
How do you tell if your CDN is earning its money? The first number you check is what fraction of requests it serves from its own cache vs forwarding to origin — that fraction is the hit ratio, and it splits into two: request hit ratio (what users feel) and byte hit ratio (what the CFO pays for). Healthy dashboard shown: request hit ratio 92%, byte hit ratio 88%, origin RPS low; the Sankey is mostly green-HIT and the thin red MISS share is spread evenly across the five buckets — no single failure mode dominates.
Highlighted lines are the ones running in the diagram right now.
def computeHitRatio(edge_logs):hits = count(l for l in edge_logs if l.cache == 'HIT')misses = count(l for l in edge_logs if l.cache == 'MISS')request_hit_ratio = hits / (hits + misses)bytes_from_cache = sum(l.bytes for l in edge_logsif l.cache == 'HIT')total_bytes = sum(l.bytes for l in edge_logs)byte_hit_ratio = bytes_from_cache / total_bytes# diverges when one big-object class missesreturn request_hit_ratio, byte_hit_ratio
def diagnose(metrics):if metrics.vary_cardinality_per_url > 5:return 'vary' # one curl, read Vary headerif metrics.ttl_avg < 60 or metrics.no_store_pct > 0.1:return 'ttl' # curl asset, read Cache-Controlif metrics.purge_rate_per_hour > 10:return 'purge' # check CI logs for zone-wide purgesif metrics.bypass_pct > 0.2:return 'bypass' # audit /api/* style rulesif metrics.cookie_in_key:return 'cookie' # strip cookies for asset pathsreturn 'investigate_origin'
- docCloudflare: Cache analytics (cache status & ratio)
- docFastly: Real-time analytics — hit ratio
- blogioRiver: Cache Hit Ratio — definition and diagnostics
- blogPatrick Meenan / WebPageTest — caching diagnostics in the wild
- codeAEM project archetype #680 — Vary: User-Agent in production
- docCloudflare community: Cache purge time / propagation effects on hit ratio
Where this sits in Build a CDN
Scene 11 of 13, in the Operating act — Shield, bypass routes, and the hit-ratio dashboard.. Request hit ratio vs byte hit ratio, and the 5-step ladder when it crashes: Vary cardinality → TTL config → purge frequency → bypass rules → cookie key.
Up next. Now that you can read the dashboard and run the ladder, the capstone asks the inverse question: design the configuration that produces a healthy one for a stated workload.