Skip to main content

Gzip and Brotli

Updated: October 29, 2026
By Willya Randika

Gzip and Brotli are compression algorithms for text assets such as HTML, CSS, JavaScript, JSON, and SVG. The server compresses, the browser decompresses, and the transfer gets smaller and faster.

The short difference

AspectGzipBrotli
SupportAlmost every browserModern browsers
RatioGoodUsually 15–25% smaller for text
Compression speedFastSlightly slower
When to useUniversal fallbackPriority for static assets

How to enable it

  • LiteSpeed/cPanel: usually on by default; check the Content-Encoding response header.
  • Nginx: enable gzip on; and the Brotli module if available.
  • CDN: many CDNs compress automatically at the edge.
  • WordPress: a cache plugin usually handles HTML and static assets.

Test with `curl -I -H "Accept

What to watch for

  • Do not compress images/video. Those formats are already compressed; the result can be larger.
  • Avoid double compression. If the CDN already compresses, the origin does not need to do it again.
  • Watch Content-Length. Compression changes the size; do not cache the wrong header.
  • Brotli needs HTTPS in many setups. Make sure the connection is secure.
  • Compression costs CPU. On a small server, measure the impact before raising the compression level.

Already-compressed files such as JPEG, PNG, WebP, MP4, and ZIP should not be compressed again. Compression helps large JSON API responses; for very small responses, header overhead can outweigh the saving. Measure with DevTools or curl before changing the configuration.

FAQ

Is Brotli always better than Gzip?

Brotli usually gives a smaller ratio, but Gzip is more universal and faster to compress. Offer both and let the browser choose.

Does compression slow the server?

It costs CPU, but that is usually much smaller than the bandwidth and transfer-time savings.

How do I confirm compression is active?

Look for `Content

  • Encoding: brorgzip` on HTML/CSS/JS responses. If it is missing, check the server or CDN configuration.

Disclaimer: Hosting Wiki articles are prepared for educational and reference purposes. Hosting technology keeps evolving, so some technical details may change over time.