Synthetic response in Fastly is a very fast and useful way to deliver static content on a webpage. This is useful for sitemaps, robots.txt and ssl verification files.

1. Instructions


This is a straight forward design to catch and return a static text response.

a. In the recv vcl, create a snippet that will send the desired page to error.


if (req.url == “/.well-known/pki-validation/gsdv.txt”) {
error 660;
return(error);
}


b. To provide a response, create a catch in the error vcl.


if (obj.status == 660) {
set obj.status = 200;
set obj.response = “OK”;
set obj.http.Content-Type = “text/plain; charset=utf8”;
synthetic {“”};
return(deliver);
}

2. It is always a good idea to keep the response codes in the 600 range. This range should not be used by another system. You will see Fastly use codes in the 900 range, that can be used as well.

More information can be found here:

https://docs.fastly.com/en/guides/creating-error-pages-with-custom-responses#creating-custom-responses-using-vcl-snippets

Recent Posts

Start typing and press Enter to search