Hear from Slack, the ACLU, TED, & more at our customer summit in San Francisco Register

Isolating header values without regular expressions

  Last updated February 15, 2017

Fastly supports the ability to extract header subfield values without regular expressions in a human-readable way.

"Headers subfields" refer to headers with a body syntax style similar to value1=123value123; testValue=asdf_true; loggedInTest=true; or max-age=0, surrogate-control=3600 These headers include Cookie, Set-Cookie, Cache-Control, or a custom header. Fastly allows you to isolate these key values with the following syntax:


In cases where a Set-Cookie response from origin is value1=123value123; testValue=asdf_true; loggedInTest=true;, the code for isolating the loggedInTest value would be:


This logic can be used in uploaded custom VCL, as well as throughout the web interface. For example, using VCL this logic would execute based on the value of staff_user within req.http.Cookie.

# in vcl_recv
if (req.http.Cookie:staff_user ~ "true") {
  # some logic goes here

For example, to isolate the value of ab_test_value from Cookie to the header req.http.AB-Test-Value, create a custom header with the following settings:

the header window showing a custom header without regular expressions

Fill out the Create a header fields as follows:

This will send the AB-Test-Value header in every inbound request.

Back to Top