LOG IN SIGN UP
Documentation

Enabling automatic gzipping

To dynamically gzip content based on file extension or content-type, follow the steps below.

  1. Log in to the Fastly web interface and click the Configure link.
  2. From the service menu, select the appropriate service.
  3. Click the Edit configuration button and then select Clone active. The service version page appears.
  4. Click the Content tab. The Content page appears.

    the Content page

  5. Click the Create gzip button. The Create a new gzip page appears.

    create a new gzip page

  6. Accept the default gzip policy by clicking Create button. The Default Gzip policy appears.

  7. Click the Create button. The new gzip policy appears.

  8. Click the Activate button to deploy your configuration changes.

Override the default gzip rule

If you want to override the default gzip rule, follow the steps below:

  1. Click the Create gzip button. The Create a new gzip page appears.
  2. Click the Override these defaults link on the page. The additional gzip fields appear.

    the Create a new gzip page

  3. Fill out the Create a new gzip fields as follows:

    • In the Name field, type an arbitrary name for your new gzip rule.
    • In the Extensions field, type the file extension for each file type to be dynamically gzipped, separated by spaces. Only type the three- or four-letter string representing the file extension. We recommend setting the Extensions to css js html eot ico otf ttf json.
    • In the Content Types field, type the content-type for each type of content you wish to have dynamically gzipped, separated by spaces. Do not use regular expressions. We recommended setting the Content Types to the following:
    text/html application/x-javascript text/css application/javascript text/javascript application/json application/vnd.ms-fontobject application/x-font-opentype application/x-font-truetype application/x-font-ttf application/xml font/eot font/opentype font/otf image/svg+xml image/vnd.microsoft.icon text/plain text/xml
    
  4. Click the Create button. The new gzip policy appears.

  5. Click the Activate button to deploy your configuration changes.

Automatic exclusion from old browsers

Some web browsers should not receive gzipped content. Fastly's default gzip configuration intentionally excludes old browsers. Specifically, we run the following VCL before any custom VCL:

if (req.http.Accept-Encoding) {
  if (req.http.User-Agent ~ "MSIE 6") {
    unset req.http.Accept-Encoding;
  } elsif (req.http.Accept-Encoding ~ "gzip") {
    set req.http.Accept-Encoding = "gzip";
  } elsif (req.http.Accept-Encoding ~ "deflate") {
    set req.http.Accept-Encoding = "deflate";
  } else {
    unset req.http.Accept-Encoding;
  }
}

Back to Top