add

Available inall subroutines.


This is a companion discussion topic for the original entry at https://developer.fastly.com/reference/vcl/statements/add

Careful about using this with the Vary header on the response (e.g. add beresp.http.Vary = "x-ft-country"). If there’s already a Vary header, then that’s going to cause another to be appended. I had assumed that Fastly would concatenate the two headers as defined in RFC2616:

Multiple message-header fields with the same field-name MAY be present in a message if and only if the entire field-value for that header field is defined as a comma-separated list [i.e., #(values)]. It MUST be possible to combine the multiple header fields into one “field-name: field-value” pair, without changing the semantics of the message, by appending each subsequent field-value to the first, each separated by a comma. The order in which header fields with the same field-name are received is therefore significant to the interpretation of the combined field value, and thus a proxy MUST NOT change the order of these field values when a message is forwarded.

But Fastly didn’t do that when I tested this, or at least it didn’t do it consistently. Sometimes Fastly would respect the first Vary header when caching the request, and sometimes it would respect the second, which was quite tricky to debug.