---
title: Variables in VCL
summary: null
url: https://www.fastly.com/documentation/reference/vcl/variables
---

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](https://www.fastly.com/documentation/reference/vcl/declarations/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:

- [Backend connection](https://www.fastly.com/documentation/reference/vcl/variables/backend-connection/)
- [Backend request](https://www.fastly.com/documentation/reference/vcl/variables/backend-request/)
- [Backend response](https://www.fastly.com/documentation/reference/vcl/variables/backend-response/)
- [Cache object](https://www.fastly.com/documentation/reference/vcl/variables/cache-object/)
- [Client connection](https://www.fastly.com/documentation/reference/vcl/variables/client-connection/)
- [Client request](https://www.fastly.com/documentation/reference/vcl/variables/client-request/)
- [Client response](https://www.fastly.com/documentation/reference/vcl/variables/client-response/)
- [Date and time](https://www.fastly.com/documentation/reference/vcl/variables/date-and-time/)
- [ESI](https://www.fastly.com/documentation/reference/vcl/variables/esi/)
- [Geolocation](https://www.fastly.com/documentation/reference/vcl/variables/geolocation/)
- [Math constants limits](https://www.fastly.com/documentation/reference/vcl/variables/math-constants-limits/)
- [Miscellaneous](https://www.fastly.com/documentation/reference/vcl/variables/miscellaneous/)
- [Rate limiting](https://www.fastly.com/documentation/reference/vcl/variables/rate-limiting/)
- [Segmented caching](https://www.fastly.com/documentation/reference/vcl/variables/segmented-caching/)
- [Server](https://www.fastly.com/documentation/reference/vcl/variables/server/)

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](https://www.fastly.com/documentation/reference/vcl/request-lifecycle/) (for `[R]eading` and `[W]riting`):

| Variable  | recv | hash | hit | miss | pass | fetch | error | deliver | log   |
| --------- | ---- | ---- | --- | ---- | ---- | ----- | ----- | ------- | ----- |
| req.\*    | R/W  | R/W  | R/W | R/W  | R/W  | R/W   | R/W   | R/W     | R/W   |
| bereq.\*  |      |      |     | R/W  | R/W  | R/W   |       |         | R 1️⃣ |
| obj.\*    |      |      | R   |      |      |       | R/W   |         |       |
| beresp.\* |      |      |     |      |      | R/W   |       |         |       |
| resp.\*   |      |      |     |      |      |       |       | R/W     | R/W   |

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

## User defined local variables

See [Local variables](https://www.fastly.com/documentation/reference/vcl/declarations/local-variables/) for information on declaring and using user defined variables.
