Enabling automatic gzipping

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

  1. Log in to the Fastly application.
  2. Click the configure tab to access the control panel.

    The configure tab

  3. Select the appropriate service from the Service menu.

  4. Click the blue Configure button to the right of the service name.

  5. Click the Content section.

    the gzip area on the Content pane

  6. In the Gzip area, click the New button to create a new gzip rule. The New Gzip window appears.

    the New Gzip window

  7. Fill in the fields of the New Gzip window as follows:

    • In the Name field, type an arbitrary name for your new gzip rule.
    • In the Extensions field, type the file extensions for each file type you wish to have dynamically gzipped, separated by spaces. Only type the file extension; the dot (.) and regular expressions are not necessary. 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
  8. Click the Create button. The new GZIP rule appears in the GZIP area of the Content section.

  9. Click Activate at the top of the window to apply the changes to your service.

Automatic exclusion from old browsers automatically

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;