How to enable Brotli or gzip compression
Text files shrink by 70-90 % when compressed on the server. It is one setting in nginx, Apache or your CDN.
Step by step, with screenshots: Brotli compression: gzip vs Brotli and how to enable it →
Check your own site
Runs this check and the other 192, free, in about 45 seconds.
Or run only this check with the free HTTP/2 & HTTP/3 test.
What it is
HTTP compression is the server shrinking text files, such as HTML, CSS, JavaScript, JSON and SVG, before sending them, and saying so in the Content-Encoding response header: br for Brotli or gzip for gzip. The browser unpacks them automatically, so nothing changes for visitors except speed.
Text typically shrinks by 70-90 %, and Brotli files are usually another 15-20 % smaller than gzip. Images, video and fonts in WOFF2 are already compressed, so compressing them again gains nothing. When a file arrives uncompressed, the cause is usually a server or CDN setting, or a third-party host you do not control.
OK looks like this: every text response carries Content-Encoding: br or gzip, including files from your CDN and subdomains. getReport checks the header on each text file the page loads and lists the ones sent uncompressed, with their host.
What a passing site looks like
- Text files are compressedwarning · −2 ptseffort S
Text compression
Why it matters. HTML, CSS and JavaScript shrink by 70-90% with gzip or Brotli. Sending them uncompressed wastes visitors' data and seconds, especially on mobile.
- Enable Brotli (or gzip) for text types in your server, hosting panel or CDN; Cloudflare and most hosts have it as one switch.
- Check the files in the technical detail; third-party ones need the vendor to fix it.
Questions people ask
What is Brotli compression?
Brotli is a compression format developed by Google and standardised in RFC 7932 in 2016. Browsers announce support with Accept-Encoding: br, and servers reply with Content-Encoding: br. For web text it usually makes files 15-20 % smaller than gzip, and every current browser supports it over HTTPS.
What is gzip compression?
gzip is the long-standing compression format for web traffic, supported by every browser and server. The server compresses a text file, sends it with Content-Encoding: gzip, and the browser unpacks it. It is the fallback when Brotli is not available, and still cuts HTML, CSS and JavaScript by around 70 %.
How do I enable Brotli in nginx?
nginx has no Brotli support built in, so add the ngx_brotli module, which many distributions and hosting panels ship as a package. Then set brotli on; a moderate brotli_comp_level such as 5; and brotli_types for text/css, application/javascript and the other text types, plus brotli_static on to serve pre-compressed .br files. Keep gzip on as the fallback and reload nginx.
Does Cloudflare compress my site automatically?
Yes. Cloudflare compresses text responses to visitors with Brotli or gzip, whichever the browser supports, on every plan, even when your server sends them uncompressed. Files your page loads from other hosts, such as a separate CDN or third-party scripts, are not covered, which is why getReport lists each uncompressed text file together with the host it came from.
Is Brotli better than gzip?
For static files, yes: Brotli usually produces files 15-20 % smaller at similar decompression speed. At its highest levels it is slow to compress, so servers use a lower level for dynamic pages or pre-compress static files. Serve Brotli where available and keep gzip as the fallback.