Cache hit Percentage is the percentage of files served through the CDN that are served from cache, instead of from proxy. A low cache hit percentage occurs when files from an origin server are not being cached on the StackPath edge servers. In a perfect world, each site would have a cache hit percentage of 100%, but there are key factors that make the cache hit percentage less than perfect.
The easiest way to avoid a low cache hit percentage is to avoid these scenarios:
- Full cache purges:
When you completely purge a site's cache, the cache hit percentage resets at 0%. The first few requests after a purge are sent to your origin - not StackPath - those requests will count as a cache miss, lowering your cache hit percentage.
- Un-cacheable content:
Some files might have a cache-control-header that prevent our Nginx servers from caching them. This is caused by the
- New files:
Similar to the full cache purge, the first few requests for new files are sent to your origin.
- Query strings:
A query string is a variable appended to a file. It's used to help browsers identify a new version of the file. Even if the original file without the query string is cached, the query string generates a new file URL. This can be corrected by disabling the query string option in your control panel.
- Local caching mechanisms:
When running a caching server like Varnish, cache control headers set by Varnish prevent the CDN from caching the files.
How to identify 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
date: Thu, 19 Mar 2020 15:28:21 GMT
last-modified: Mon, 24 Feb 2020 14:13:49 GMT
The x-hw header ends with .p, which indicates that the file was pulled from the origin when requested. You can read more about the x-hw header here.
If you still have a low cache hit percentage, please contact our support team through a ticket or live chat 24/7/365!