Brotli Compression
Brotli is a compression method that usually makes text files smaller than GZIP. This Pro feature adds Brotli on top of the GZIP setup that xSpeed Cache already writes, so browsers that support Brotli get the smaller files and everyone else keeps GZIP.
What this does
Brotli compresses text such as HTML, CSS, and JavaScript around 15 to 25 percent smaller than GZIP. It needs a server that supports it (mod_brotli on Apache, ngx_brotli on nginx, or built-in support on LiteSpeed).
This feature is additive. It does not replace the Free GZIP setup. Instead it:
- Appends Brotli directives to the compression rules xSpeed Cache already writes for GZIP.
- Can pre-compress your cached files by writing a
.brcopy next to each static cache file, so the server serves Brotli without compressing on every request.
Browsers that ask for Brotli (with Accept-Encoding: br) get the Brotli version. Browsers that do not keep getting GZIP or the plain file. Nothing about the GZIP setup changes.
Why use it
- Text files are smaller than with GZIP alone, so pages transfer faster.
- Pre-compressed
.brfiles mean the server does not spend time compressing on every request. - GZIP stays in place as an automatic fallback, so no visitor is left without compression.
Requirements
- xSpeed Cache Pro must be active.
- Your server needs Brotli support:
mod_brotlion Apache,ngx_brotlion nginx, or LiteSpeed with native Brotli turned on. - To pre-compress
.brfiles, PHP needs thebrotliextension. Without it, the server can still compress Brotli on the fly if it supports it, but xSpeed Cache cannot write.brfiles.
How to enable it
- Go to the xSpeed Cache dashboard in your WordPress admin.
- Open the Brotli Compression panel.
- Switch on Enable Brotli.
- Leave Pre-compress cached files on so xSpeed Cache writes
.brcopies of your cache files. - Check the panel status to confirm Brotli is actually being served on your server.
When you turn Brotli on, xSpeed Cache re-writes the server compression config so the Brotli rules are added right away. On Apache, this goes into the same marked block that holds the GZIP rules.
Settings explained
| Setting | What it does | Default |
|---|---|---|
| Enable Brotli | Adds Brotli directives to the server config and pre-compresses cached files | Off (false) |
| Pre-compress cached files | Writes a .br copy of each static cache file so the server does not compress on every request | On (true) |
| Compression quality | Brotli quality level, from 0 to 11. Higher is smaller but slower to compress | 11 |
Enable Brotli. The main switch. When on, xSpeed Cache appends Brotli directives to the compression config and, if pre-compression is on, writes .br files. It needs a Brotli-capable server. Default is off.
Pre-compress cached files. When on, xSpeed Cache writes a .br copy of each static cache file (for example index.html.br next to index.html). The server can then hand the pre-compressed file straight to capable browsers instead of compressing it each time. This needs the PHP brotli extension to produce the files. Default is on.
Compression quality. Brotli quality from 0 to 11. Higher values make smaller files but take longer to compress. Because static files are compressed once and served many times, a high value pays off, so 11 is the default. Values outside 0 to 11 are clamped into range.
How to check if Brotli is working
Turning Brotli on does not always mean Brotli is served. Your server still needs the module or extension. xSpeed Cache reports the real state on the panel and through a status check, so you are not left guessing.
The status describes one of these situations:
- Active with pre-compression. The PHP
brotliextension is present, so cached files are pre-compressed to.brand served to capable browsers. This is the best case. - Active, served on the fly. Your server compresses Brotli itself, but the PHP
brotliextension is missing, so.brpre-compression is skipped. Install the extension to avoid recompressing on every request. - LiteSpeed detected. Brotli works only if native Brotli is turned on in your LiteSpeed or OpenLiteSpeed config. xSpeed Cache cannot verify that from PHP.
- Not available. Brotli is enabled but no Brotli-capable server module or PHP extension was found. Responses fall back to GZIP.
Note: If Brotli is enabled but nothing on the server can serve it, visitors quietly get GZIP instead. The panel flags this so you know to install
mod_brotli,ngx_brotli, or the PHPbrotliextension.
Best practices
- Keep GZIP enabled. Brotli sits on top of it, and GZIP is the fallback for browsers or servers that do not support Brotli.
- Keep Pre-compress cached files on when the PHP
brotliextension is available. It saves the server from compressing the same file over and over. - Leave quality at 11 for static files. They are compressed once, so the extra time is worth the smaller size.
- Check the panel status after enabling, so you confirm Brotli is really being served and not silently falling back to GZIP.
Troubleshooting
- Brotli is enabled but responses still use GZIP. No Brotli module or extension was detected. Install
mod_brotli(Apache),ngx_brotli(nginx), or the PHPbrotliextension. On LiteSpeed, turn on native Brotli in the server config. - No
.brfiles are being written. Pre-compression needs the PHPbrotliextension. Without it, xSpeed Cache cannot create.brfiles, though the server may still compress Brotli on the fly if it supports it. - The Brotli rules did not appear on Apache. xSpeed Cache re-writes the compression block when you change Brotli settings. Make sure the
.htaccessfile in your site root is writable and that GZIP’s marked block exists. - I changed quality but nothing in the config changed. Quality only affects the
.brfiles xSpeed Cache writes, not the server rules. Changing quality alone does not rewrite the.htaccessblock, which is expected.
FAQ
Does Brotli replace GZIP? No. It is added alongside GZIP. Browsers that support Brotli get it, and everyone else keeps GZIP.
What is a .br file?
It is a pre-compressed Brotli copy of a cache file, saved next to the original (for example index.html.br). The server can serve it directly instead of compressing the file on each request.
Do I need the PHP brotli extension?
Only for pre-compressing .br files. If your server compresses Brotli on the fly, Brotli can still be served without the extension, but the files are compressed on each request.
Which files does Brotli compress? Text-based responses such as HTML, CSS, JavaScript, XML, JSON, SVG, and web fonts. Already-compressed formats are not re-compressed.
Related
- GZIP Compression
- How to Enable Page Cache
- Browser Cache Settings