fastly_info.state
STRING, read-only.
Available inall subroutines.
State of the request, with optional suffixes describing special cases.
While this variable is available throughout the VCL request lifecycle, it is updated as the state of the request changes. It can be considered final in vcl_deliver
and vcl_log
.
States:
Value | Description |
---|---|
NONE | No state assigned. |
HIT | The request has matched previously-cached content as a result of a cache lookup. |
HITPASS | The cache key associated with this request has been previously marked uncacheable in vcl_fetch , which will trigger a PASS and prevent the resulting backend response from being cached. Never a final state. |
HIT-STALE | The request has matched previously-cached, stale content as a result of a backend failure or a return(deliver_stale) statement. |
HIT-SYNTH | The request has transited vcl_error as a result of a network error during a backend fetch or an explicit error statement, and a synthetic response has been created with a non-error status code. |
MISS | The request has been or will be sent to a backend server as a result of failing to find suitable content in cache. |
PASS | The request has been or will be sent to a backend server as a result of an explicit return(pass) or because a hit-for-pass object was found in cache. |
Error states:
Value | Description |
---|---|
BG-ERROR-[state] | An error occurred during a background fetch in [state] (possible options: PASS , RECV , ERROR ). |
ERROR | Transited vcl_error with a response code of 400 or higher. |
ERROR-LOSTHDR | Fastly ran out of memory during header processing. |
Suffixes:
Value | Description |
---|---|
-CLUSTER | The request has been transferred to a second cache node due to clustering. |
-REFRESH | A backend fetch returned a 304 Not Modified response, and Fastly is therefore able to serve cached content that would otherwise be considered stale. |
-WAIT | This request was collapsed with other requests and placed in a queue because a compatible request was already in progress. |
Try it out
fastly_info.state
is used in the following code examples. Examples apply VCL to real-world use cases and can be deployed as they are, or adapted for your own service. See the full list of code examples for more inspiration.
Click RUN on a sample below to provision a Fastly service, execute the code on Fastly, and see how the function behaves.
Comprehensive logging
Fastly offers a myriad of different variables that you can log. See and test a large collection here.