New Gzip Settings and Deciding What to Compress
At Fastly, we care about making our customers’ websites faster. Compressing responses using gzip is a performance best practice that speeds up pages by reducing payloads by ~70%.
But this requires picking the right resources to compress. In some cases, responses can actually increase in size when compressed. It’s important to understand which responses should be compressed and which should pass through unchanged.
Fastly recently conducted an extensive analysis of which resources should be compressed. Today, the results of that analysis are reflected in the Fastly app, which allows our customers to adopt better gzip settings. This not only makes our customers' websites faster, but it will also reduce monthly bandwidth charges. Better performance and reduced costs make it a double win!
New Gzip Settings
With today’s update, here are the default gzip settings for Fastly customers:
The changes are shown in bold and focus on certain types of text, images, and fonts. These specific types were selected based on an extensive analysis of data from the HTTP Archive, which Fastly is proud to support. (Fastly recently became the newest sponsor of the HTTP Archive, an open source project that collects performance data on the world’s top URLs as part of the Internet Archive digital library.)
Deciding What to Compress
For best results, it’s important to determine which responses to gzip based on the file extension or the content type. In many cases, one of these is accurate, but not both. For example, only 17% of
.json responses have a content type that contains
json. Most of them are
image/gif, and 3% have no content type. Similarly, most
.eot responses have a content type of
font/eot, but 17% are
application/vnd.ms-fontobject, 6% are
application/octet-stream, and 3% are
Fonts in general should be compressed, but not always. TrueType fonts (
ttf) and OpenType fonts (
otf) should be compressed, but Web Open Font Format (
woff) fonts should not be compressed (they’re already compressed). The answer is unclear when it comes to Embedded OpenType (
eot) fonts. It’s possible to compress EOT font files as part of the file creation process, in which case gzipping them is unnecessary. However, to generate compressed EOT font files requires a special tool and an extra step, so it’s likely that most of them are not pre-compressed. Examining the 460K
.eot responses in the HTTP Archive shows that the website owner specifically gzipped them 79% of the time. Therefore, gzipping EOT fonts is a good default.
When it comes to images, it’s generally assumed that content types starting with
image/ should never be compressed. While that’s true for a majority of images (including
GIF), it’s not true for icons and
SVG responses. The average
.ico response is over 5KB uncompressed, but gzipping them cuts the transfer size in half. For
image/svg+xml content types, the uncompressed average of 13KB is reduced by 60% when gzipped. (Look at bigqueri.es for the detailed results.)
Update Your Fastly Configuration
In order to get these compression benefits, Fastly customers should update their service configuration as described here: “How do I enable automatic gzipping?” Responses that are already cached without compression need to expire or be purged in order for the new gzip settings to take effect. It’s best if responses are compressed on the origin server; this speeds up the response time between origin and Fastly. Setting up good gzip settings in Fastly ensures that the best compression always happens between Fastly and the end user.
These improved gzip settings will make your website faster and reduce your monthly bandwidth charges. It might seem contradictory for Fastly to reduce your bill, but our goal is to make our customers more successful. We look forward to using that extra bandwidth to serve all the new users our customers will get from having a faster website!