To save bandwidth and make your application or site faster, the Vercel Edge Network cache implements two compression algorithms: gzip and brotli.
While gzip
has been around for quite some time, brotli
is a relatively new compression algorithm built by Google that best serves text compression. brotli
also has an advantage over gzip
since it uses a dictionary of common keywords on both the client and server-side, which gives a better compression ratio.
These compression methods are widely used to allow for the best performance and least maintenance.
To leverage compression on the Edge Network, you should use the Accept-Encoding
request header.
Any client that sends a request to your deployment needs to define the Accept-Encoding header to opt into compression. Many clients (e.g., browsers like Chrome, Firefox, and Safari) already do this out of the box. If you're requesting another type of client, make sure you use the Accept-Encoding
header to take advantage of compression.
To compress using brotli:
Accept-Encoding: br
An example Accept-Encoding
header requesting brotli compression.
Alternatively, some clients might not support it, so to use gzip:
Accept-Encoding: gzip
An example Accept-Encoding
header requesting gzip compression.
If your client supports brotli, it's recommended over gzip because:
brotli
compressed Javascript files are 14% smaller thangzip
.- HTML files are 21% smaller than
gzip
, and - CSS files are 17% smaller than
gzip
.
Assuming that the program requests deployment resources with the appropriate Accept-Encoding
header, the response will be compressed automatically.
The Vercel Edge Network regularly maintains a configuration file for the MIME types that will be compressed for both gzip
and brotli
:
- application
atom + xml
javascript
json
ld + json
manifest + json
rss + xml
geo + json
vnd.ms - fontobject
x - web - app - manifest + json
xhtml + xml
xml
rdf + xml
wasm
- font
otf
- image
bmp
svg + xml
- text
cache - manifest
css
dns
javascript
plain
markdown
vcard
calendar
vnd.rim.location.xloc
vtt
x - component
x - cross - domain - policy
// MIME types compressed by `gzip` and `brotli`