Cache Hit Ratio
Definition
Cache hit ratio is hits divided by total requests. Ninety hits and ten misses in a hundred requests is 90 percent, and the remaining ten are the ones that travelled to the origin server and back. Some providers also report a byte hit ratio, which weights by size rather than count, and the two diverge sharply when a handful of large files miss while thousands of tiny ones hit. Misses are not all failures: a cold miss is the unavoidable first request for a file in a given location, an eviction miss happens when the cache filled up and dropped something, and a configuration miss is a file that was never cacheable in the first place. That last category is the one worth hunting. For a static site of images, stylesheets, scripts and documents, anything below about 90 percent means something is wrong in the headers.
Why It Matters
The gap between 95 and 80 percent sounds small and is not. On a million requests a day, 95 percent sends 50,000 to the origin and 80 percent sends 200,000 — four times the load and four times the egress, from a change in a single header. Visitors feel it too, because a miss is a full round trip to wherever the origin lives: 30 milliseconds becomes 300 for a reader on the other side of the world. The ratio is also the fastest diagnostic you have. A site that was at 96 percent and dropped to 60 overnight has almost certainly started sending a Cache-Control value that prevents storage, or has introduced a query string that varies per visitor and splits one cached object into thousands.
How It Works
Each edge node keys its stored objects by a cache key, normally the hostname plus the path, sometimes plus selected query parameters or headers named in Vary. A request whose key is present and fresh is a hit; anything else is a miss and is fetched from the origin. Individual responses usually say which happened in a vendor header such as X-Cache: HIT or X-Cache: MISS, and an Age header shows how long the copy has been held. Three things move the number: longer freshness lifetimes set with max-age and s-maxage, a tidy cache key that strips tracking parameters like utm_source and avoids Vary on anything differing per visitor, and a shield node in front of the origin that turns dozens of cold misses into one.
Real-World Example
A publisher hosts a 30 MB sample chapter on 99helpers at draycott-books.99helpers.site ahead of a launch, and it is downloaded around 8,000 times in a week. Nearly all of those are served from nodes near the reader, so the file leaves storage a few dozen times rather than 8,000 — the difference between roughly 1 GB of origin traffic and 240 GB. The publisher manages none of it; caching headers and distribution come with the file on 99helpers. What they do see is the download count in the analytics, which counts every reader either way.
Common Mistakes
- ✕Reading the count-based ratio alone — a high percentage with a poor byte ratio means your large files are the ones missing, which is where the cost actually is
- ✕Leaving tracking parameters in the cache key — the same file arriving with fifty different utm_source values becomes fifty entries, each cold
- ✕Chasing 100 percent — cold misses and revalidations are normal, and a site with real content updates will never get there
- ✕Judging it in the first hour after a purge or a deploy — caches are empty by definition and the number climbs back over the following minutes
Related Terms
CDN
A content delivery network: a set of servers spread across the world that keep copies of your files and answer each visitor from somewhere close to them. It is the service; the machines it runs on are its edge network.
Cache-Control
The HTTP response header that tells browsers and caches whether they may keep a copy of a file, for how long, and who is allowed to. It is the single biggest lever over how fast a site feels on a second visit.
Edge Network
The fleet of servers a delivery provider runs in cities around the world, positioned close to visitors rather than close to your origin. It is the machinery a CDN is built from.
Origin Server
The machine or service holding the authoritative copy of a site, which a cache asks whenever it does not already have what a visitor wanted. Origin is a position in a delivery chain, not a kind of software.
Time to First Byte
Time to First Byte, or TTFB, is the gap between a browser starting a request and the first byte of the response body arriving. It measures everything that has to happen before the page can begin — not how long the page takes to finish.
Put a file online in seconds
Drop in a document, an image, a page or a whole static website and share the link — free, with no build step and no server to set up.
Host a file free →