LOG IN SIGN UP
Documentation

Understanding cache HIT and MISS headers with shielded services

  Last updated July 17, 2017

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 delivering cache node at the shield datacenter and cache-sjc3120-SJC serving as the delivering cache node at the "local" datacenter. 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 was queried for that object and not its current state, which at the time of the first request, was a MISS. The object is now cached in both datacenters.

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-sjc3122-SJC
X-Cache: MISS, HIT
X-Cache-Hits: 0, 1

This third request shows a new cache (cache-sjc3122-SJC) being selected from the local datacenter. It registers as a HIT as the object is cached in the local datacenter, with the MISS still reflecting the state of the shield datacenter when it was originally requested. The X-Cache-Hits shows 0, 1 reflecting the 0 from the shield datacenter and the 1 for the first hit on cache-sjc-3122-SJC.

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