Skip to main content

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

FeatureGzipBrotli
Compression ratioGoodBetter (15-25% smaller)
Browser supportUniversalAll modern browsers
CPU costLowerHigher at max levels
Best forDynamic content, fallbackStatic pre-compressed assets
Requires HTTPSNoYes (browsers only request over HTTPS)

Enabling Brotli

OpenLiteSpeed supports Brotli compression natively. In WebAdmin:

  1. Navigate to Server ConfigurationTuning
  2. Ensure Enable Brotli Compression is set to Yes
  3. Set an appropriate compression level (4-6 for dynamic, higher for static pre-compression)
  4. 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