UPDATE: Thank you for all your valuable comments! Following your suggestions I decided to move some of the information you provided to main body of the article to make it easier for others to find in the future.
Akamai servers are configured to provide plenty of useful information using HTTP headers - the key to extracting this information is making a HTTP request along with some custom Pragma headers. Below is the most commonly used set of Pragma request headers:
Pragma: akamai-x-cache-on, akamai-x-cache-remote-on, akamai-x-check-cacheable, akamai-x-get-cache-key, akamai-x-get-ssl-client-session-id, akamai-x-get-true-cache-key, akamai-x-get-request-id
And here is the explanation of what can be extracted using these headers as a response from Akamai Edge Server:
This header simply indicates whether this particular URL can be cached on Akamai or not.
Request ID provides a unique request identifier on Akamai network. Value of this header can be used to trace a request on Akamai network by support representative.
X-Cache: TCP_MISS from a165-254-246-9.deploy.akamaitechnologies.com
X-Cache-Remote: TCP_HIT from a23-67-252-148.deploy.akamaitechnologies.com
Values of X-Cache headers mention which Akamai servers participated in serving your request. TCP_MISS/TCP_HIT will tell whether the content was served from cache (TCP_HIT) or if the machine had to go forward to fetch the file from somewhere else (TCP_MISS). X-Cache headers can also give an IP address of Akamai machine serving the content - as in the example above - the machines serving content are 165-254-246-9 and 23-67-252-148 - just replace dashes with dots and you will get an exact Akamai IP address!
A few other useful cache responses (Thank you Iain Hunneybell!):
- TCP_HIT: Object was fresh in cache and object from disk cache.
- TCP_MISS: Object was not in cache, server fetched object from origin.
- TCP_REFRESH_HIT: Object was stale in cache and was successfully refreshed with the origin on an If-Modified-Since request.
- TCP_REFRESH_MISS: Object was stale in cache and refresh obtained a new object from origin in response to our IF-Modified-Since request.
- TCP_REFRESH_FAIL_HIT: Object was stale in cache and failed on refresh (couldn't reach origin) so the stale object was served .
- TCP_IMS_HIT: IF-Modified-Since request from client and object was fresh in cache and served.
- TCP_NEGATIVE_HIT: Object previously returned a "not found" (or any other negatively cacheable response) and that cached response was a hit for this new request.
- TCP_MEM_HIT: Object was on disk and in the memory cache. Server served it without hitting the disk.
X-Cache-Key: /L/152/14351/1d/origin-www.akamai.com/index2.html * - depracated
This header will return a Cache Key value which is used to store content on Akamai network.
There's also crucial information in the X-Cache-Key (Thank you Iain Hunneybell!):
That /1d/ means the item is on a 1 day cache setting. Useful if you want to check. Useful ones to look out for are:
- 0s: 0 second cache meaning serve from cache but revalidate on every request, e.g. check origin but don't re-download unless changed
- 000: Non-cacheable...a key code to recognise
- 5s: 5 (or however many) seconds
- 5m: 5 (or however many minutes)
- 5h: You'll never guess this one!
Small point (Thank you Neil Jedrzejewski!):
akamai-x-get-cache-key has actually been deprecated because it doesn't indicate if a query string has been ignored in the cache key. It also shows serial, CP Code and TTL, which are not part of the cache key used to store the object.
While the information given in X-Cache-Key is useful it can be misleading, for example the TTL shown won't reflect any baseline value being overridden by origin cache-control or edge control headers. It can also show extra query parameters added by internal processes like RUM or FEO.
You should use akamai-x-get-true-cache-key and X-True-Cache-Key to get the real cache key used to store the object. It will represent the parts of the original URI used to form the key after any metadata rule processing.
Akamai Pragma HTTP headers can be injected into your request by one of the browser extensions or one of HTTP debugging applications. Some most popular examples include:
- Charles Proxy - HTTP/Web Debugging Proxy software
- Fiddler - free web debugging proxy
- Modify Headers Firefox plugin
- Firebug - another powerful Firefox plugin
Using Akamai Pragma headers allows for easy troubleshooting of content cacheability, Akamai IP servers' assignment and many more. You can also use the gathered information to troubleshoot further using Akamai Tools in Luna Control Center (you can learn more about Luna troubleshooting tools from this great article Luna Diagnostic Tools -- An Introduction by Arthi Maran) Feel free to add your comment if you can think of any other helpful troubleshooting scenarios with the usage of Pragma headers.