LOG IN SIGN UP
Documentation

Curl and other caching verification methods

The easiest way to tell if your request is caching in the Fastly network is to use a cURL on the command line. We recommend using one of two cURL commands for debugging purposes:

Using the simple cURL command

The following cURL command displays the request and response headers for a given object:

curl -svo /dev/null www.example.com/index.html

where www.example.com/index.html is replaced with the full object path of the object you're testing.

For example, using curl -svo /dev/null www.example.com produces something like the following section of output:

[...]

< Age: 142
< X-Served-By: cache-jfk1041-JFK, cache-ord1720-ORD
< X-Cache: HIT, HIT
< X-Cache-Hits: 1, 7

[...]

This output tells us the current age of the object in cache. It also shows shielding is enabled because two cache nodes display in X-Served-By. However, we're most interested in the output of the X-Cache header. A properly caching object displays a value of X-Cache: HIT, X-Cache: HIT, HIT, X-Cache: HIT, MISS, or X-Cache: MISS, HIT.

Using a Fastly-Debug header with cURL

The Fastly-Debug header provides additional information for debugging by exposing specific information that is normally stripped when using a simple cURL command:

curl -svo /dev/null -H "Fastly-Debug:1" www.example.com/index.html

where www.example.com/index.html is replaced with the full object path of the object you're testing.

For example, with optional shielding being used and a TTL set to 86400 (24 hours) using Surrogate-Control, the command curl -svo /dev/null -H "Fastly-Debug:1" www.example.com produces something like the following section of output:

[...]

< Surrogate-Control: max-age=86400
< Surrogate-Key: articles articles/1 articles/2

[...]
< Age: 403
< Fastly-Debug-Path: (D cache-ord1722-ORD 1470672957) (F cache-ord1743-ORD 1470672629) (D cache-jfk1041-JFK 1470672629) (F cache-jfk1030-JFK 1470672554)
< Fastly-Debug-TTL: (H cache-ord1722-ORD 85997.246 0.000 403) (H cache-jfk1041-JFK - - 75)
< X-Served-By: cache-jfk1041-JFK, cache-ord1722-ORD
< X-Cache: HIT, HIT
< X-Cache-Hits: 1, 6

[...]

Because surrogate keys are present, the Fastly-Debug header exposes them. As with the simple cURL command, this section of output tells us the current age of the object in cache. In addition, Fastly-Debug exposes specific header details to help with debugging as noted below.

Information exposed by the Fastly-Debug header

Fastly-Debug Path contains information about which cache server handles fetching and delivery of an object and object TTL information. The edge POP appears first in the sequence and the shield POP appears second.

With shielding enabled, you should generally see four cache servers listed in this header. In rare cases where a cache server exists as both an edge and a shield within the cluster for that object, you may see two or three caches listed.

Fastly-Debug-TTL provides information on HIT and MISS timings.

For each of these timings:

Because the cluster node determines these values, it may take a few requests to see these numbers populate as expected.

X-Served-By indicates the shield and edge servers that were queried for the request. The shield POP appears first in the sequence and the edge POP appears second.

X-Cache: indicates whether the request was a HIT or a MISS for the datacenter.


Back to Top