Enabling automatic gzipping

Fastly supports gzip data compression to speed up information transmission. The Fastly gzip feature dynamically fetches content from origin, compresses it, and then caches it. There are two ways to enable gzip:

  • Based on file extension. Enable the default gzip policy to compress content in files with the following extensions: css js html eot ico otf ttf json svg.
  • Based on content type. Set up an advanced gzip policy to customize the content and conditions for compression.

Enabling gzip

To dynamically gzip cacheable content based on file extension or content-type, follow the steps below to enable the default gzip policy:

  1. Log in to the Fastly web interface.
  2. From the Home page, select the appropriate service. You can use the search box to search by ID, name, or domain.
  3. Click the Edit configuration button and then select the option to clone the active version. The Domains page appears.
  4. Click the Content link. The Content page appears.
  5. Click the Default gzip policy switch to enable gzip.
  6. Click the Activate button to deploy your configuration changes.

Setting up an advanced gzip policy

To customize the content that’s compressed and the conditions under which this compression occurs, follow the steps below:

  1. Log in to the Fastly web interface.
  2. From the Home page, select the appropriate service. You can use the search box to search by ID, name, or domain.
  3. Click the Edit configuration button and then select the option to clone the active version. The Domains page appears.
  4. Click the Content link. The Content page appears.
  5. Click the Set up advanced gzip button. The Create a gzip page appears.
  6. Click the Override these defaults link. Additional gzip fields appear.

    Create a new gzip

  7. Fill out the Create a gzip fields as follows:
    • In the Name field, enter an arbitrary name for your new gzip rule.
    • In the Extensions field, enter the file extension for each file type to be dynamically gzipped, separated by spaces. Only enter the three- or four-letter string representing the file extension.
    • In the Content Types field, enter the content-type for each type of content to dynamically gzip, separated by spaces. Do not use regular expressions.
  8. Click the Create button. The new gzip policy appears.
  9. Click the Activate button to deploy your configuration changes.

Limitations and considerations

This feature has the following limitations and considerations you should take into account:

  • The automatic gzip feature can only compress cacheable content.
  • Content already compressed at origin will be cached as-is. We will not attempt to re-compress it.
  • As a best practice, we recommend compressing content at the origin whenever possible to improve performance and reduce costs (e.g., cloud egress charges).
Back to Top