Available inall subroutines.
Fastly only supports the following ESI directives:
When specifying the src URL with
<esi:include src=... />, the URL can be either an absolute or relative URL. If you specify an absolute URL, you must prefix it with
<esi:include src="https://example.com/index.html" />
ESI requests are made to your Fastly service as new client requests, with a copy of the HTTP header information from the original client request. If a hostname is specified in the ESI
src attribute, the
Host header of the new request will be set to the value of that hostname, otherwise the
Host header of the ESI request will be the same as for the parent request.
In the above example, the ESI parser takes
example.com in the URL as the
Host request header value (i.e.,
req.http.host) and creates a new request to your service. Although you can specify any URL in an ESI include, and the hostname does not have to be one of your service's configured domains you can only forward that request to one of your configured backends. In general, it is often better to use relative links for ESI includes to avoid confusion.
ESI tags are processed sequentially, not concurrently, because when the parser encounters an ESI include tag, it will make the child request, wait for the HTTP response from the child request to complete, splice that response into the response stream, and then continue parsing the parent response.
- The maximum depth of
- The maximum total
esi:includeprocessing fragments is
It is not possible for edge logic within a child request to pass data back to the parent, except by embedding the response body of the child request within the parent. However, it is possible to know whether a request is an ESI child request by checking the value of
In order for the ESI parser to detect
<esi:... tags in the response stream, the response cannot be compressed. Compressed responses will obfuscate the ESI tags and they will be delivered unprocessed to the client.
esi 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.
Convert timestamps to relative times like '2 hours ago'
Assemble content at the edge with Edge-side includes (ESI)
Use Fastly's support for ESI to combine multiple origin-hosted objects into a single response at the edge.