Cache Hit Ratio (CHR)

By Jonas Krummenacher
Updated on February 20, 2022
Cache Hit Ratio (CHR)

The cache hit ratio (CHR) gives precise information about the amount of files served from the CDN without any requests to the origin server. In this post we will highlight what has an impact on CHR and what can be done to improve it. The cache hit ratio will only apply for Pull Zones.

The CHR is measured among all files served from a Pull Zone regardless of the file size or file type. The CHR can significantly vary depending on the environment and the setup. A typical CHR for a normal website can easily be as high as 95%.

A number of factors can influence the CHR in various ways:

  • Query strings: If query strings are not ignored, each query string will create a new cache entry. This can be an important feature to distinguish different version of a file but it will cause extra cache entries if not used properly. Query strings can be ignored (see Zone settings) and regardless of the query string, it will always be cached as the same file.
  • Expire headers: KeyCDN will honor all HTTP headers from the origin server (and overwrite them as defined in the Zone settings). It's important to define meaningful Cache-Control and Expire values.
  • Purge: Each purge (either the entire Zone or one particular file) will delete the content on all POPs globally. The file(s) will then be cached again.
  • New files: Every new file needs to be initially fetched and cached from each POP all around the world. This will result in one cache miss for each file and POP.
  • User generated content (long tail content): The traffic pattern will also have a great impact on the CHR. In case of user generated content, new files need to be cached all the time (which will lead to a lower CHR).
  • Not cacheable content: Not all files are cacheable. Files will only be cached based on the Cache-Control header. Files with cookies will not be cached if the cookie is not stripped away (see Zone settings).

How to check a cache status

The X-Cache HTTP header will indicate, if the request has been a cache hit or miss. This can easily be checked with the following curl command:

**curl -I https://example-hexid.kxcdn.com/img/logo.png**
HTTP/1.1 200 OK
Server: nginx
Date: Sun, 02 Nov 2014 04:48:02 GMT
Content-Type: image/png
Content-Length: 6396
Connection: keep-alive
Vary: Accept-Encoding
Last-Modified: Sat, 26 Apr 2014 12:11:29 GMT
ETag: "535ba271-18fc"
Alternate-Protocol: 443:npn-spdy/3,443:npn-spdy/2
Strict-Transport-Security: max-age=31536000; includeSubdomains; preload
Expires: Sun, 09 Nov 2014 04:48:02 GMT
Cache-Control: max-age=604800
Link: <https://www.keycdn.com/img/logo.png>; rel="canonical"
**X-Cache: MISS**
X-Edge-Location: nlam
Access-Control-Allow-Origin: *
Accept-Ranges: bytes

Alternatively, the HTTP headers can also be checked online with tools like our HTTP Header Checker tool.

If the CHR is lower than expected, it's important to take a closer look and narrow down the possible root cause. In most cases it can be improved with the steps proposed above.

Happy caching!

  • Share

Supercharge your content delivery 🚀

Try KeyCDN with a free 14 day trial, no credit card required.

Get started

Comments

Comment policy: Comments are welcomed and encouraged. However, all comments are manually moderated and those deemed to be spam or solely promotional in nature will be deleted.
  • **bold**
  • `code`
  • ```block```
KeyCDN uses cookies to make its website easier to use. Learn more