LOG IN SIGN UP
Documentation

Understanding cache HIT and MISS headers with shielded services

Here's some help deciphering cache hit and miss headers when you have shielding enabled. Let's look at the following requests for the same object if you had run a cURL command in your terminal (for example, curl -svo /dev/null www.example.com) to return the Fastly headers.

The first request for an object using the above cURL command might produce output something like this:

X-Served-By: cache-iad2120-IAD, cache-sjc3120-SJC
X-Cache: MISS, MISS
X-Cache-Hits: 0, 0

For this first request, the two cache-nodes in X-Served-By show that shielding is turned on, with cache-iad2120-IAD serving as the cache node and cache-sjc3120-SJC serving as the local delivering node. The X-Cache: MISS, MISS indicates that the requested object was neither in the shield cache (a MISS) nor the local delivering node (also a MISS). The X-Cache-Hits reflects that same MISS information because it displays 0, 0.

The second request for an object using the above cURL command might produce output something like this:

X-Served-By: cache-iad2120-IAD, cache-sjc3120-SJC
X-Cache: MISS, HIT
X-Cache-Hits: 0, 1

This second time, we hit the same local cache-node (cache-sjc3120-SJC) and got a HIT. The MISS listed for cache-iad2120-IAD reflects the state of that node the last time it queried that node for that object (not its current state), which at that time was a MISS, but in fact, the object resides in that cache now because it was requested from origin.

Waiting a minute or two and requesting the same object a third time using the above cURL command might produce output something like this:

X-Served-By: cache-iad2120-IAD, cache-sjc3120-SJC
X-Cache: HIT, MISS
X-Cache-Hits: 1, 0

This third request shows a new cache (cache-sjc3120-SJC) being selected, MISSing, and retrieving the object from the shield node (cache-iad2120-IAD), which had the object (a HIT). In total, there should have only been a single request for this object to the origin.

Keep in mind that if the closest delivering cache node exists in the shield datacenter, you will only see a single server and HIT data such as:

X-Served-By: cache-iad2120-IAD
X-Cache: HIT
X-Cache-Hits: 1

After a purge of the object, requesting the object again via the above cURL command will produce results similar to the first request scenario. For example:

X-Served-By: cache-iad2120-IAD, cache-sjc3120-SJC
X-Cache: MISS, MISS
X-Cache-Hits: 0, 0

Back to Top