Movatterモバイル変換


[0]ホーム

URL:


  1. Home
  2. Reference documentation
  3. HTTP references

Header reference

Fastly cache servers read and write HTTP headers as part of the process of caching and routing requests and responses. This section defines all the headers that are meaningful to Fastly and how they affect the way a Fastly service will behave.

Edge Platform

API

Media Products

Reading and setting HTTP headers

InVCL, it's possible to read and write HTTP headers on the incoming client request (req.http.{NAME}), the request to the backend (bereq.http.{NAME}), the response from the backend (beresp.http.{NAME}), or the response to the client (resp.http.{NAME}). It's also possible to read and write headers on a cache object (obj.http.{NAME}) in some parts of the VCL flow.

To set the value of a header, use theset oradd statements:

setreq.http.Custom-Header="some=1, data=2, here=3";
setreq.http.Another-Header="header-values-can-be-any-string-data";

While you can set the value of a header in any format you like, usingstructured fields is a good way to make the values easier to parse later. In fact, if you use this format, you can access subfields using a convenience syntax in VCL:

setreq.http.Cache-Control:max-age="3600";

This subfield accessor syntax also works for reading headers:

if (req.http.cookie:cookie-name) {
# Do something with the 'cookie-name' cookie
}

Some headers, such asVary, take a list of keys (in the case ofVary, a list of other header names), but no values. Subfield syntax can be used to add or remove keys from these kinds of headers:

setresp.http.Vary:Accept-Encoding="";// Add "Accept-Encoding" to the Vary header
unsetresp.http.Vary:User-Agent;// Remove "User-Agent" from the Vary header

[8]ページ先頭

©2009-2025 Movatter.jp