A cache hit ratio is useful only when its numerator, denominator and measurement point are clear. A single percentage cannot tell you whether visitors received the right content, whether an origin was contacted for validation, or whether a large download dominated transferred bytes. Define the measurement before using it as a target.
The arithmetic and investigation plan below are illustrative. They describe how a developer can evaluate a cache, not measured results or available reporting features of Mirage CDN.
Define what counts as a hit
RFC 9211 defines the Cache-Status response field. Its hit parameter means the cache satisfied the request without forwarding it. A stored response that needs an upstream validation request is not a hit under that definition, even when the origin returns 304 and the stored body is reused. RFC 9211, hit parameter
That distinction matters when comparing reports. A report may group validated responses with hits, while another groups them with forwarded requests. Neither percentage is interpretable until you inspect the classification. Record the reporting rule beside the chart. If a field is absent, mark the result unknown instead of guessing from how quickly the response arrived.
For a request hit ratio, use a defined request population:
request hit ratio = cache hits / measured requests
Suppose a sample contains 800 cache hits and 200 forwarded requests. Under this definition the ratio is 80%. If you exclude deliberately bypassed routes, report that exclusion and its count. Otherwise a later change in the amount of account traffic can appear to be a caching regression even when public asset behavior is unchanged.
Measure bytes separately
For a byte hit ratio, define the counted bytes and sum them consistently:
byte hit ratio = body bytes served on hits / body bytes delivered
Imagine 90 hits delivering 10 KB each and 10 misses delivering 1 MB each, using decimal units. The request hit ratio is 90%, while the byte hit ratio is approximately 8.3%. This invented workload demonstrates why the two figures answer different questions. Large files can dominate transfer volume without dominating request count.
Content coding changes transferred representation sizes. A compressed body and its decoded contents need not contain the same number of bytes, so a report must state which quantity it measures. Content-Encoding reference
Range requests add another accounting decision. A successful partial response can contain only the selected byte interval and use status 206. Count actual delivered body bytes for the formula above, and document whether repeated ranges are separate requests. Do not replace each partial response with the full object’s size. HTTP range requests
Find the largest avoidable source of misses
Start with a small classification: absent object, expired response, deliberate bypass, changed cache key and request requiring validation. RFC 9211 includes forwarding reasons and other diagnostic parameters that can help distinguish these cases when an implementation emits them. It also warns that cache information can disclose details, so diagnostic exposure deserves review. RFC 9211
Use aggregate counts where possible. For each class, select a public fixture and reproduce the behavior. Keep the investigation focused: if expired responses dominate, inspect their intended freshness policy; if many apparently identical assets miss, compare the full request URLs and relevant headers.
A query component participates in URI identification. Two URLs that differ in query data are not automatically equivalent, and URI normalization is not permission to discard application semantics. RFC 3986, query and comparison
For example, /photo.jpg?width=320 and /photo.jpg?width=640 might deliberately identify different outputs. Removing width from a key could improve a percentage while returning the wrong image. By contrast, an application may discover that a campaign parameter changes no bytes. Any normalization should follow a documented equivalence test, with authorization parameters and meaningful representation choices preserved.
Change policy only with a correctness test
Prepare one hypothesis at a time. If a stylesheet changes only when its versioned filename changes, test a longer freshness policy for that fixture. If a document is intentionally mutable, agree on an acceptable update delay before extending its lifetime. Verify the new body after publication, then compare equivalent observation windows.
Some deployments support targeted cache-control fields. RFC 9213 defines CDN-Cache-Control and how a cache selects a targeted policy. Support must be established for the actual cache; adding a header is not evidence that an implementation applies it. Keep browser and shared-cache expectations in the test record. RFC 9213
Do not increase reuse by sharing personalized responses, ignoring valid variation, or suppressing necessary origin checks. An optimization is acceptable only when the content, access policy and update behavior remain correct. The HTTP caching headers guide provides the vocabulary for that review.
Compare useful observation windows
Annotate releases, purges and measurement changes. Compare the same routes, byte definition and request classification before and after an adjustment. Include origin request counts and error counts beside the ratios. A smaller origin workload with correct updates is a more meaningful result than a larger percentage produced by excluding difficult requests.
Keep the final report reproducible: list the fixture, policy, interval, counters and exclusions. If the sample is too small or a field is missing, say so. A precise limited measurement gives the next investigation a reliable starting point.
Sources
- RFC 9211: The Cache-Status HTTP Response Header Field
- RFC 3986: URI Generic Syntax
- RFC 9213: Targeted HTTP Cache Control
- Content-Encoding reference
- HTTP range requests
This guide explains technical concepts. For your delivery setup, review the documentation and request an account from our team.
Read the integration docs · Explore more CDN guides