What is a cache hit ratio?
Cache hit ratio is a measurement of how many content requests a cache is able to fill successfully, compared to how many requests it receives. A content delivery network (CDN) provides a type of cache, and a high-performing CDN will have a high cache hit ratio.
The formula for calculating a cache hit ratio is as follows:
For example, if a CDN has 39 cache hits and 2 cache misses over a given timeframe, then the cache hit ratio is equal to 39 divided by 41, or 0.951. The cache hit ratio can also be expressed as a percentage by multiplying this result by 100. As a percentage, this would be a cache hit ratio of 95.1%.
Cache hit ratio is a metric that applies to any cache; it's not just for measuring CDN performance. However, it is an especially important benchmark for CDNs. Most CDN services will provide customers with this metric within their user interface or dashboard.
What is a cache hit?
A "cache hit" occurs when a file is requested from a cache and the cache is able to fulfill that request. For instance, if a user visits a webpage that's supposed to display a picture of a cat playing a piano, the browser may send a request to the webpage's CDN for this picture. If the CDN has a copy of the picture in its storage, then the request results in a cache hit, and the picture is sent to the browser.
What is a cache miss?
A cache miss is when the cache does not contain the requested content. If a copy of the cat-playing-piano picture is not currently in the CDN cache, this request results in a cache miss, and the request is passed along to the origin server for the original picture. The CDN server will cache the photo once the origin server responds, so that additional requests for it will result in a cache hit.
What is a good CDN cache hit ratio for most websites?
A typical website that's mostly made up of static content could easily have a cache hit ratio in the 95-99% range. However, getting this metric as high as possible isn't the only goal of a CDN. Additionally, a website with lots of dynamic content may have a much lower cache hit ratio (although caching dynamic content is becoming possible).
Does a high cache hit ratio always mean a CDN is effective?
Cache hit ratio is not the last word in CDN performance; other factors are extremely important in assessing a CDN's effectiveness as well. For instance, where the content is served from is also important. Ideally, a CDN will serve content from the CDN server closest to the end user. If this doesn't occur, the CDN's performance will not be optimal. The Cloudflare CDN is built to serve any content from any of our 193 locations around the world. Any content that is cached in one data center) can be served from every other data center as well.
Caching is an important part of what a CDN does, but its main purpose is to make web properties faster and more reliable in general. A variety of performance metrics help measure how much a CDN has helped to speed up a web app or website.