Available inerror

The synthetic statement replaces the content of the cache object's response body with the specified string, when processing an error state.

Typically, synthetic responses are used to create customised error messages or responses to API calls, but can be used to serve full pages of content, and are often employed for site-wide metadata such as robots.txt files.

Being a STRING, if the content argument to the synthetic statement contains any null bytes (0x00), the first instance of a null byte will terminate the string. synthetic is therefore not a good choice for generating non-textual content, and you may prefer to use synthetic.base64 instead.

Try it out

synthetic is used in the following solution recipes, which show real world use cases. Click RUN to provision a Fastly service, execute the code on Fastly, and see how the function behaves.

Relative date insertion using ESI

Generate relative time datelines like "3 minutes ago" at the Edge instead of in JavaScript or at origin. Better caching, faster rendering, fewer reflows.

Serve robots.txt from the edge

Include full text of robots.txt in VCL, serve as a synthetic response to avoid robots.txt requests hitting your origin.

Client public IP API at the edge

Quickly fetch the user's public IP from an API endpoint on your own domain, with no origin.

User contributed notes

We welcome comments that add use cases, ideas, tips, and caveats. All comments will be moderated before publication. To post support questions, visit our support center and we'll find you the help you need.