Brotli usually compresses text files such as HTML, CSS and JavaScript to a smaller size than gzip, so it is the better choice when your server or CDN supports it. Keep gzip enabled as a fallback for clients that do not ask for Brotli. Either one is far better than sending text uncompressed.
Why it matters
Smaller responses download faster, which helps Largest Contentful Paint, especially on slow mobile connections. Compression only applies to text-like content. Images such as JPEG, PNG-optimised files, WebP and AVIF are already compressed, and compressing them again wastes processor time for little gain.
The browser and server agree on the method with two headers:
- The browser sends
Accept-Encoding: gzip, deflate, br. - The server answers with
Content-Encoding: brorContent-Encoding: gzip.
Browsers only advertise Brotli (br) over HTTPS, so make sure the site uses HTTPS.
How to check
- Ask your server for the compressed version and read the response headers:
curl -sI -H "Accept-Encoding: br" https://example.com/ | grep -i content-encoding
curl -sI -H "Accept-Encoding: gzip" https://example.com/ | grep -i content-encoding
- If the first command prints
content-encoding: br, Brotli works. If only the second printsgzip, gzip works and Brotli is not enabled. - In Chrome DevTools, open the Network panel, select a file and look for
content-encodingin the response headers. - Check CSS and JavaScript files too, not only the HTML page.
How to turn it on
- If you use a CDN, look for a Brotli or compression setting and switch it on.
- On your own server, enable the Brotli module and gzip, and list the content types to compress, such as
text/html,text/css,application/javascript,application/jsonandimage/svg+xml. - For static files, consider compressing them ahead of time at a high level. For pages built on request, use a moderate level so compression does not slow the response.
- Re-run the header check above to confirm.
Common mistakes
- Compressing already-compressed formats such as JPEG, MP4 or ZIP.
- Enabling compression for HTML only and forgetting CSS, JavaScript, JSON and SVG.
- Using the highest Brotli level for every dynamic response, which can raise server response time.
- Testing over plain HTTP and concluding Brotli does not work.
Frequently asked questions
Do I need to choose between them?
No. Servers can offer both. The browser's request lists what it accepts, and the server picks the best match, so Brotli goes to browsers that support it and gzip covers the rest.
Will Brotli change my rankings?
No direct effect is promised. It reduces bytes transferred, which can improve loading speed for visitors.
Is compression safe for every file?
It is safe for text. For files that are already compressed it brings little benefit and uses processing time, so leave them out.
Related guides
- Gzip and Brotli compression guide
- Improve your Lighthouse performance score
- Fix a slow Largest Contentful Paint
- Reduce JavaScript bundle size
Crawvix's scan checks that text compression is on. To see how your site does, Try the free website sample.