Brotli Compression
Learning Focus
By the end of this lesson you will understand how Brotli differs from gzip, when to use it, and how to enable it in OpenLiteSpeed.
What Brotli Offers Over Gzip
Brotli typically provides 15-25% better compression ratios than gzip for text content, meaning smaller file sizes and faster page loads for modern browsers.
Gzip vs Brotli
| Feature | Gzip | Brotli |
|---|---|---|
| Compression ratio | Good | Better (15-25% smaller) |
| Browser support | Universal | All modern browsers |
| CPU cost | Lower | Higher at max levels |
| Best for | Dynamic content, fallback | Static pre-compressed assets |
| Requires HTTPS | No | Yes (browsers only request over HTTPS) |
Enabling Brotli
OpenLiteSpeed supports Brotli compression natively. In WebAdmin:
- Navigate to Server Configuration → Tuning
- Ensure Enable Brotli Compression is set to
Yes - Set an appropriate compression level (4-6 for dynamic, higher for static pre-compression)
- Save and Graceful Restart
Verifying Brotli
# Request with Brotli support
curl -sI -H "Accept-Encoding: br" https://example.com | grep -i "content-encoding"
# Expected: content-encoding: br
info
Brotli is ideal for static assets where CPU cost is amortized. For dynamic content, a moderate compression level (4-6) balances speed and size. Browsers only request Brotli over HTTPS.
Key Takeaways
- Brotli provides better compression than gzip but uses more CPU.
- It is ideal for static assets served repeatedly.
- Brotli requires HTTPS — browsers will fall back to gzip over HTTP.
What's Next
- Return to the Performance Optimization module for the complete overview.