Fastly Setup

The following screenshots illustrate how to configure Fastly to deliver content. Essential settings are marked with a red circle.

Create a Fastly service

Go to the Fastly Management UI and select Create Service:

Add Domain

Add your production domain (e.g. www.mydomain.com):

Configure Origin

Add your origin (e.g. main--mysite--hlxsites.hlx.live):

Click on the pencil to edit the new origin:

Scroll down and change Shielding to Ashburn Metro (IAD) (non-mandatory but recommended setting) and Override host to the hostname of your origin (same as Address above, e.g. main--mysite--hlxsites.hlx.live) (mandatory setting):

Enable Gzip

Create VCL Snippets

Create a VCL snippet for the recv subroutine with the following VCL code:

if (req.url.path !~ "/media_[0-9a-f]{40,}[/a-zA-Z0-9_-]*\.[0-9a-z]+$" 
  && req.url.ext !~ "(?i)^(gif|png|jpe?g|webp)$"
  && req.url.ext != "json"
  && req.url.path != "/.auth") {
  // strip query string from request url
  set req.url = req.url.path;
}

Create VCL snippets for the miss and pass subroutines with the following VCL code:

set bereq.http.X-BYO-CDN-Type = "fastly";
set bereq.http.X-Push-Invalidation = "enabled";

NB: The X-Push-Invalidation: enabled request header enables the push invalidation incl. long cache TTLs.


miss snippet:

pass snippet:

Finally create a deliver snippet with the following VCL code:

unset resp.http.Age;

After completing all steps and activating the service version you should be all set: