Available in all subroutines.
Sets the value of a variable or HTTP header.
set var.custom_string_variable = "foo";set obj.status = 307;set obj.http.Location = "/login";
set will overwrite the value of an existing header (to append instead, see
add). To set a single token in a comma-separated list of key-value pairs in the header value,
set also supports subfield accessors:
set resp.http.Cache-Control:max-age = "300";set resp.http.Vary:Accept-Encoding = ""; # empty string adds "Accept-Encoding" to the header value as a standalone token
set statement allows for a variety of operators:
Try it out
set 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.
Add, remove or change HTTP headers
Fastly can easily read and write HTTP headers at multiple stages of the request/response cycle.
Math assignment operators
Use addition, subtraction, multiplication, division, and modulus operators when assigning numeric values to headers or variables.