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:

ValueDescription
NONENo state assigned.
HITThe request has matched previously-cached content as a result of a cache lookup.
HITPASSThe 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-STALEThe request has matched previously-cached, stale content as a result of a backend failure or a return(deliver_stale) statement.
HIT-SYNTHThe 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.
MISSThe request has been or will be sent to a backend server as a result of failing to find suitable content in cache.
PASSThe 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:

ValueDescription
BG-ERROR-[state]An error occurred during a background fetch in [state] (possible options: PASS, RECV, ERROR).
ERRORTransited vcl_error with a response code of 400 or higher.
ERROR-LOSTHDRFastly ran out of memory during header processing.

Suffixes:

ValueDescription
-CLUSTERThe request has been transferred to a second cache node due to clustering.
-REFRESHA backend fetch returned a 304 Not Modified response, and Fastly is therefore able to serve cached content that would otherwise be considered stale.
-WAITThis 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.