Brotli Compression
Your gzip was fine. Brotli is better.
nginx-module-brotli Install
Make sure you have the official nginx.org repository configured first. These packages require nginx from nginx.org, not the distro-bundled version.
Add the Blendbyte repository if you haven't already:
sudo install -d -m 0755 /etc/apt/keyrings
curl -fsSL https://apt.blendbyte.net/nginx/blendbyte-archive-keyring.gpg \
| sudo tee /etc/apt/keyrings/blendbyte.gpg >/dev/null
echo "deb [signed-by=/etc/apt/keyrings/blendbyte.gpg] https://apt.blendbyte.net/nginx $(lsb_release -cs) main" \
| sudo tee /etc/apt/sources.list.d/blendbyte.list
sudo apt update Then install this module:
$ sudo apt install nginx-module-brotli Most modules auto-enable on install. If yours didn't, enable it manually:
$ sudo ln -s /etc/nginx/modules-available/50-mod-brotli.conf \
/etc/nginx/modules-enabled/
$ sudo nginx -t && sudo systemctl reload nginx What it does
Brotli is a general-purpose lossless compression algorithm developed at Google. Compared to gzip at equivalent speeds, it squeezes text content 15-25% smaller. Every major browser has supported it for years. nginx does not ship with it. This module fixes that. It works dynamically: nginx compresses responses on the fly based on the Accept-Encoding request header. Pair it with nginx-module-brotli-static if you want to pre-compress files at build time and skip the CPU cost entirely.
When to use it
- Reduce bandwidth usage and page load times for HTML, CSS, and JS assets
- Improve Core Web Vitals scores by shrinking Time to First Byte on text content
- Replace or supplement gzip compression without touching application code
- Serve smaller API responses to JavaScript clients
Configuration
A starting-point configuration. Adjust to your setup.
# Inside your http {} block:
brotli on;
brotli_comp_level 6;
brotli_types
text/html
text/css
text/plain
application/javascript
application/json
application/xml
image/svg+xml; Replacing a Sury package?
This module replaces libnginx-mod-http-brotli-filter from the Sury nginx repository.
The package declares Replaces and Conflicts so apt handles
the swap automatically in one transaction.
# If you were using Sury, this upgrades in place:
sudo apt install nginx-module-brotli See the full migration guide for the complete Sury-to-Blendbyte migration steps.
Upstream project
This module is packaged from the upstream open-source project. Bug reports about module behaviour (not packaging) should go upstream.
https://github.com/google/ngx_brotli ↗