Illustration of a cache hit ratio: a donut gauge with a high share of hits beside a stack of cached files and a funnel of requests

The cache hit ratio is the first number most people check on a CDN dashboard, and the one most often misread. A single percentage can look healthy while the origin carries the heavy lifting.

What does a cache hit ratio actually measure?

Wikipedia's article on caches defines a cache hit as a request found in the cache and a cache miss as one that isn't, and calls the percentage of accesses that result in hits the hit rate or hit ratio. Hits are served faster than recomputing or refetching, so a higher ratio means a faster system. That definition counts requests. It says nothing about size.

Say a zone serves 100,000 requests a day. 80,000 are 20 KB assets that hit the cache. The remaining 20,000 are misses: 19,500 small files (20 KB each) and 500 downloads of 40 MB each. The request hit ratio is 80%. The byte numbers tell a different story:

  • Bytes served from cache: 80,000 x 20 KB = 1.6 GB
  • Small misses: 19,500 x 20 KB = 0.39 GB
  • Large misses: 500 x 40 MB = 20 GB
  • Byte hit ratio: 1.6 / (1.6 + 0.39 + 20) = 1.6 / 21.99 = 7.3%

So 80% of requests were hits, yet more than 92% of the bytes came from the origin. For bandwidth bills and origin load, the byte ratio matters. For page speed, the request ratio on the small, render-critical files matters. Tracking both takes ten minutes and prevents a false sense of safety.

Why does the ratio fall even on a well-configured zone?

NetDNA's support article on a low cache hit percentage lists the usual causes, and they still describe how caches behave. The percentage starts at 0% each day and builds up, so a reading at 9 a.m. isn't comparable to one at 9 p.m. A purge of the zone resets it to 0%. New files count as misses on their first request. Files with no-cache or a very short lifetime in their headers can't be kept. And a local caching layer such as Varnish can send headers that stop the CDN from caching what Varnish is already holding.

The query-string case deserves its own mention. Suppose a theme adds ?ver=4.2 to 400 static files and a plugin appends a session token to some of them. If each unique string becomes its own cache key, the edge stores a separate copy for each, and visitors rarely request the same one twice. The files are cached, but the hits never come.

Five changes that raise the ratio

Each of these has a reason, so they can be tested one at a time.

  1. Find the uncacheable files first. Run curl -sI https://www.example.com/app.css and read cache-control. A no-cache or max-age=0 on a static file is the most common culprit, and it's a one-line fix at the origin.
  2. Replace query-string versioning with fingerprinted filenames. app.91c3.css changes its name when its content changes, so it can live a year without ever going stale. Our query-string caching guide covers the settings if renaming isn't possible.
  3. Purge single URLs, not whole zones. Since a full purge resets the ratio to 0%, purging only the changed file keeps the rest of the cache warm. See CDN purge.
  4. Give static files long lifetimes. NetDNA's default lifetime for a pull zone is 24 hours, according to its custom-expiry article, and a longer value from the origin is honoured. A 30-day lifetime on images means a file can be requested thousands of times per origin fetch.
  5. Remove header conflicts between layers. If Varnish or a plugin adds Cache-Control: private, the CDN follows it. Fix the header where it starts.

What is a realistic target, and what does it save?

Targets depend on content, so a universal number would mislead. Mostly static sites with fingerprinted assets can sit well above 90% on requests; sites with heavy personalisation sit lower for HTML and high for assets. What helps more than a target is knowing what a step change is worth.

Say your edge receives 40,000 requests a day for cacheable files. At a 70% hit ratio, 12,000 requests reach the origin (40,000 x 30%). Raise the ratio to 90% and only 4,000 do (40,000 x 10%). That's 8,000 fewer origin requests, a cut of two thirds (8,000 / 12,000 = 66.7%) from a 20-point improvement. The same logic shows why the last few points are worth chasing: going from 90% to 95% halves the origin traffic again, from 4,000 to 2,000.

Origin shields add to this effect. Wikipedia's CDN article describes an origin shield as a layer that protects the origin server during heavy traffic; with one, a miss at several edge locations becomes a single request to the origin.

Reading the ratio so it leads to an action

A dashboard number only helps when it points somewhere. A workable routine: compare the same hour of day week over week, list the ten URLs with the most misses, and check each one's headers with curl. Nine times out of ten, the same three patterns show up: a short lifetime, a query string, or a purge after deploy. Fix the pattern and the ratio follows.

Related: Low cache hit percentage, Cache-Control headers, EdgeRules.