Variables in VCL

VCL provides many predefined variables that describe the state and properties of a request, as well as a mechanism for declaring local variables.

Local variables are scoped to the subroutine or block in which they are defined. Predefined variables have different scopes depending on their purpose and content, with availability indicated on each variable's reference page.

Predefined variables

Explore all available variables here:

Several predefined variables relate to various views of the HTTP exchange: the client request (req), backend request (bereq), backend response (beresp), cached object (obj), and client response (resp). These are accessible in their respective parts of the VCL lifecycle (for [R]eading and [W]riting):

Variablerecvhashhitmisspassfetcherrordeliverlog
req.*R/WR/WR/WR/WR/WR/WR/WR/WR/W
bereq.*R/WR/WR/WR 1️⃣
obj.*RR/W
beresp.*R/W
resp.*R/WR/W

1️⃣ A small number of bereq. variables are available to read in the vcl_log subroutine.

User defined local variables

See Local variables for information on declaring and using user defined variables.