Compression can help you reduce the size of your assets so traffic can flow faster. You can use Fastly to compress data automatically on our edge servers.
Much of the data delivered by Fastly can be compressed using static compression, especially text-based formats like HTML, JavaScript, and CSS. Static compression fetches content from origin, compresses it according to the user's requested format (either Brotli or gzip), and then caches it.
Dynamic compression, on the other hand, compresses content just before responses are delivered to the client and is used on content that canât be cached. For example, dynamic compression can compress content unique to an end user.
Limitations and caveatsKeep in mind the following:
When considering the general behavior of Fastly's compression feature, keep in mind the following:
This section demonstrates how to use the Fastly control panel to enable and disable static compression for cacheable content. To enable compression, select a compression format and then set up a compression policy.
WARNING: Enabling static compression or changing the compression format immediately impacts all service versions, including the active one.
Selecting a compression formatTo enable compression, start by selecting a compression format using the steps below:
Log in to the Fastly control panel.
From the Home page, select the appropriate service. You can use the search box to search by ID, name, or domain.
Click Edit configuration and then select the option to clone the active version.
Click Content.
Once you've selected the compression format, you'll need to set up a compression policy. Decide whether to:
css
, js
, html
, eot
, ico
, otf
, ttf
, json
, or svg
file extensions.To enable the default compression policy, follow these steps:
Click Activate to deploy your configuration changes.
To set up an advanced compression policy, follow these steps:
Click Set up advanced compression.
Click Override these defaults.
Fill out the Create a compression policy fields as follows:
Click Create. The new compression policy appears.
Click Activate to deploy your configuration changes.
If you're currently using the default compression policy, you can disable compression by clicking the Default compression policy switch to display OFF
.
If you're currently using an advanced compression policy, you can disable compression by deleting it using the trash to the right of the policy's title:
WARNING: Disabling static compression immediately impacts all service versions, including the active one.
Automatic normalizationBecause compression is one of the most common reasons to vary output based on a request header, Fastly will normalize the value of Accept-Encoding
on incoming requests. The modified header will be set to a single encoding type, or none, and will reflect the best compression scheme supported by the browser.
Specifically, we run the following steps on inbound requests:
User-Agent
matches a pattern for browsers that have problems with compressed responses, remove the Accept-Encoding
headerAccept-Encoding
header includes the string br
, set the entire value to the string br
Accept-Encoding
header includes the string gzip
, set the entire value to the string gzip
Accept-Encoding
header includes the string deflate
, set the entire value to the string deflate
Accept-Encoding
headerWhere this normalization process has changed the header value, the original value is made available in the custom header Fastly-Orig-Accept-Encoding
.
Fastlyâs Dynamic Content Compression feature allows you to compress dynamic content that wouldnât benefit from caching, like video streaming manifests and dynamic content from Compute applications. Once compressed, you are also able to apply dynamic web content assembly techniques like ESI. Our guide to delivering compressed content through Fastly discusses how to enable compression using custom VCL or the Fastly API via the X-Compress-Hint header and includes workflows for compressing dynamic content.
Related contentRetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4