Check the cache status of a response
Send one request with a debug header and read whether Azion served the response from its cache, together with the key the copy is stored under.
You check whether Cache served a response from a stored copy by requesting the object with a debug header and reading two response headers. The check runs from any machine with curl, and it needs no change to the application.
The same response carries the cache key the copy is stored under, which is the argument a cache key purge takes. For the key format and every status value, refer to Cache keys.
Prerequisites
curlon your machine.- The URL of an object your application serves.
Request the debug headers
The request header Pragma: azion-debug-cache makes Azion return the cache state of the response. To read it:
The -I flag asks for the response headers alone, so the body is not downloaded:
The x-cache header carries three values: the cache status, the IP address of the server that answered the request, and the protocol. Under HTTP/2, the header names arrive in lowercase:
The x-cache-key header carries the key the copy is stored under. A cache key purge takes that value as its argument.
Compare the status of the second response with the first.
You now know whether the response came from the cache, from the origin, or was not cached at all.
Read the status
HIT means the response was served from a stored copy and the origin was not asked. MISS means the object was not in the cache, so Azion fetched it from the origin and may store the response for later requests. A - in both headers means the content is restricted from caching.
The other values a response can carry are EXPIRED, STALE, UPDATING, REVALIDATED, and BYPASS. For what each one means, refer to Cache keys.
A - on a POST or OPTIONS request means caching is off for that method. To turn it on, refer to Cache POST and OPTIONS responses.