Vercel CDN Compression
Vercel helps reduce data transfer and improve performance by supporting both Gzip and Brotli compression. These algorithms are widely used to compress files, such as HTML, CSS, and JavaScript, to reduce their size and improve performance.
While has been around for quite some time, is a newer compression algorithm built by Google that best serves text compression. If your client supports brotli, it takes precedence over gzip because:
- compressed JavaScript files are 14% smaller than
- HTML files are 21% smaller than
- CSS files are 17% smaller than
has an advantage over since it uses a dictionary of common keywords on both the client and server-side, which gives a better compression ratio.
Many clients (e.g., browsers like Chrome, Firefox, and Safari) include the request header by default. This automatically enables compression for Vercel's CDN.
You can verify if a response was compressed by checking the response header has a value of or .
The following clients may not include the header by default:
- Custom applications, such as Python scripts, Node.js servers, or other software that can send HTTP requests to your deployment
- HTTP libraries, such as in Node.js, and networking tools, like or
- Older browsers. Check MDN's browser compatibility list to see if your client supports by default
- Bots and crawlers sometimes do not specify in their headers by default when visiting your deployment
When writing a client that doesn't run in a browser, for example a CLI, you will need to set the request header in your client code to opt into compression.
When the request header is present, only the following list of MIME types will be automatically compressed.
The compression allowlist above is necessary to avoid accidentally increasing the size of non-compressible files, which can negatively impact performance.
For example, most image formats are already compressed such as JPEG, PNG, WebP, etc. If you want to compress an image even further, consider lowering the quality using Vercel Image Optimization.
Was this helpful?