February 3, 2015
Our system honors all the cache control headers sent from the origin server, so a low cache hit percentage (CHP) means that while the static files are being served via your CDN, not all of them are being cached. The CHP starts every day from 0% and builds up during the day until it reaches its maximum. With perfect CDN integration, the CHP will reach 100% every day, but there are some things that will cause the CHP to not increase:
- Purging the cache:
When a Pull Zone’s cache is purged, the CHP will reset to 0%.
- Not all files are cache-able:
Some files might have a cache-control-header which will prevent our NginX servers from caching them. Some headers would be a “no-cache”, or a very low TTL.
- New files:
When new files are added to the CDN, this will affect the CHP and prevent it from reaching 100%.
- Query String:
A query string is a variable that appends to a file, usually used to to identify a new version of the file for the browser to recognize (for example, style.css?qstring=2). Because of this, even if the main file is cached, the query string generates a new file URL, preventing the man cached file from being served. You can correct this by disabling the query string option in Pull Zone → Advanced Features in the control panel.
- Local Caching Mechanisms:
When running a caching server like Varnish, the cache control headers set by Varnish will prevent the CDN from caching the files.
Identifying non-cache-able files
By using the “curl” command that on Linux and Unix/OS X the results would look as follows:
# curl -I static.examplesite.net/css/style.css HTTP/1.1 200 OK Date: Mon, 27 Aug 2012 00:06:33 GMT Content-Type: text/css Connection: keep-alive Last-Modified: Fri, 24 Aug 2012 10:45:17 GMT ETag: "1f37e38-89f0-4c800abf294a8" Vary: User-Agent Expires: Tue, 28 Aug 2012 00:06:33 GMT Cache-Control: max-age=86400 Server: NetDNA-cache/2.2 X-Cache: MISS
The X-Cache: MISS indicates that the file is being pulled from the origin when requested. The same result can be achieved by using the file path in the Cache Inspector.
Resolving the low CHP problem
The simplest way to avoid low CHP, is to avoid all the contributing factors previously mentioned. If you already have, and you are still getting a low CHP, contact our Support Team for assistance.