Brotli (brotli.org, Google) is a compression algorithm 15-25% better than gzip for text (HTML/CSS/JS). Client support 95%+ by 2026. Install in nginx: compile ngx_brotli module (not in the default dynamic pool) or use the nginx-extras package. Add 3 directives + server reload.
Below: step-by-step, working examples, common pitfalls, FAQ.
Free online tool — page speed test: instant results, no signup.
apt install nginx-module-brotli (Ubuntu 22.04+)git clone --recursive https://github.com/google/ngx_brotli + configure nginx with --add-moduleload_module modules/ngx_http_brotli_filter_module.so; load_module modules/ngx_http_brotli_static_module.so;brotli on; brotli_comp_level 6; brotli_types text/plain text/css application/json application/javascript;brotli_static on;nginx -t && systemctl reload nginxcurl -H "Accept-Encoding: br" -I https://example.com | grep -i "content-encoding" — should be "br"| Scenario | Config |
|---|---|
| nginx.conf modules | load_module modules/ngx_http_brotli_filter_module.so;
load_module modules/ngx_http_brotli_static_module.so; |
| server block | brotli on;
brotli_comp_level 6;
brotli_static on;
brotli_types text/plain text/css application/json application/javascript application/xml+rss text/xml image/svg+xml; |
| Pre-compress files | find /var/www -type f \( -name "*.css" -o -name "*.js" \) | xargs -I{} brotli -q 11 "{}" |
| Apache | LoadModule brotli_module modules/mod_brotli.so\nBrotliCompressionQuality 5 |
To enable Brotli compression in Nginx, you need to install the Brotli module, configure it in your Nginx configuration file, and set the appropriate directives. Use the command sudo apt install nginx-module-brotli to install the module, then add brotli on; and brotli_types text/html text/css application/javascript; in the relevant server block to activate Brotli compression for specified file types.
Enabling Brotli compression in Nginx is a straightforward process that can significantly enhance the performance of your web applications by reducing the size of transmitted data. Follow these steps to activate Brotli compression on your Nginx server.
Before proceeding, ensure you have the following:
To use Brotli compression, you need to install the Brotli module for Nginx. Depending on your operating system, the installation process may vary.
For Ubuntu/Debiansudo apt updatesudo apt install nginx-module-brotliFor CentOS/RHELUse the following commands to install the Brotli module:
sudo yum install epel-releasesudo yum install nginx-mod-http-brotliOnce the Brotli module is installed, you need to configure Nginx to enable Brotli compression. Open your Nginx configuration file, usually located at /etc/nginx/nginx.conf or within the /etc/nginx/conf.d/ directory.
sudo nano /etc/nginx/nginx.confWithin the http block, add the following configuration:
brotli on;brotli_static on;brotli_types text/html text/css application/javascript application/json image/svg+xml;This configuration enables Brotli compression and specifies the MIME types that should be compressed. Adjust the MIME types according to your application needs.
You can further customize Brotli settings with options like brotli_comp_level and brotli_vary. The brotli_comp_level directive controls the compression level, where a value of 1 is the fastest and 11 is the most compressed:
brotli_comp_level 6;The default value is 6, which provides a good balance between compression ratio and CPU usage. The brotli_vary directive enables the Vary header for browsers that support Brotli, which helps in caching:
brotli_vary on;After making changes, test your Nginx configuration for syntax errors:
sudo nginx -tIf there are no errors, reload Nginx to apply the changes:
sudo systemctl reload nginxTo confirm that Brotli compression is working, you can use tools such as GiftOfSpeed or Check Gzip Compression. These tools will show you whether Brotli is enabled and provide details on the compression ratio.
Enabling Brotli compression in Nginx can significantly improve the loading times of your web applications, enhancing user experience and potentially boosting SEO rankings. By following the steps outlined above, you can easily set up Brotli compression and optimize your server's performance.
Page load speed directly impacts conversion, SEO rankings, and user satisfaction. Google uses Core Web Vitals as a ranking factor. Every extra second of load time cancost up to 7% in conversions.
Google Lighthouse-based analysis: Performance, Accessibility, Best Practices, SEO.
LCP (rendering), FID (interactivity), CLS (visual stability) — key Google metrics.
Breakdown by type: HTML, CSS, JavaScript, images, fonts. Size, request count, blocking resources.
Specific recommendations with savings estimates: image compression, caching, minification, etc.
Core Web Vitals for rankings
performance optimization
speed = conversions
performance regression
async/defer block rendering. Move to end or add attribute.Cache-Control, the browser reloads CSS/JS on every visit.loading="lazy" for images below the fold.brotli on;Cache-Control: max-age=31536000, immutable. HTML: max-age=0, s-maxage=60.<link rel="preload"> for fonts and CSS. Reduces LCP by 200-500ms.Speed check history, competitor comparison and PageSpeed monitoring.
Sign up freeFor text (HTML/CSS/JS): 15-25% smaller at the same CPU. For binaries (already compressed) — minimal.
Yes; clients don't send Accept-Encoding: br over plain HTTP. Modern sites are all HTTPS.
Chrome 50+, Firefox 44+, Safari 11+ (2017). IE no support. By 2026 coverage is 95%+.
<a href="/en/speed">Enterno Speed checker</a> shows response headers. Or DevTools → Network → Response Headers → Content-Encoding.
Free plan — 10 monitors, checks every 5 min, no card required. Upgrade for 1-minute interval and multi-region monitoring.