[WP] Gzip vs Brotli Compression: The Difference Between the Two Compression Algorithms

Test environment RHEL familyAlmaLinux 9.8Nginx + ApacheChecked 2026-10-18

To make websites, including those built with the WordPress CMS, faster, it is useful to set up data compression on the server. This lets the data transferred between the web server and the browser load faster and speeds up the website as a whole. It is one of the factors website administrators think about most. Gzip compression is widely used, and on many web servers there is a growing shift from gzip to Brotli compression.

1️⃣ What Is Compression?

Site URL: when you open it, a conversation begins between the browser and the server. At this point the browser tells the server whether it can undo content compression (Compression) and which compression algorithms it uses. This helps the browser decompress the data correctly when the server sends it compressed. So with a server and browser that support compression algorithms, your website loads even faster.

Data compression

When a web browser connects to a server, it sends headers such as gzip or Brotli compression. Data compressed with one of the two is delivered to the browser, and compressed data loads faster than uncompressed data.

Content-encoding: gzip
Content-encoding: br
The files that get compressed are mainly text:
· HTML
· CSS
· JavaScript

2️⃣ What Is Gzip Compression?

The common compression algorithms used by web hosts are Gzip and Brotli. Gzip's beta came out in 1992, and version 1.0 was released in 1993. In general, Gzip is one of the standard ways to compress data sent over the internet. It is based on DEFLATE, an early compression algorithm, and takes its name from gzip, a file compression program developed earlier for Unix.

Gzip file

DEFLATE combines the LZ77 (Lempel-Ziv 1977) algorithm with Huffman coding. LZ77 searches for repeated data, finds matching strings and replaces them with codes. Huffman coding uses how often each character appears to assign the shortest bit codes.

Gzip compresses data with DEFLATE and, using the ‘Accept-Encoding: gzip’ header in HTTP requests and responses, compresses only when the client supports Gzip. This compression helps websites load faster.

3️⃣ What Is Brotli Compression?

Brotli was developed in 2013 by Google engineers Jyrki Alakuijala and Zoltán Szabadka.

Brotli compression

Gzip was originally meant for compressing files, but it was adapted for use on the web as well. Brotli, on the other hand, was  developed for use on the web from the start. So with Brotli, the web server can compress content before sending it to the browser. Because it is compressed before being streamed to the browser, it is a better, more advanced approach.

Brotli uses the same two core techniques as GZIP compression: LZ77 and Huffman coding.

4️⃣ Gzip Compression vs Brotli Compression

🧭 Compression Flow by Accept-Encoding
Explainer diagram
📨 Request header
🌐 Request
gzip
br
No header
gzip, deflate, br, zstdEdge 155
→Request
🖥️ Nginx
📄 CSS · JS files served directly
🗜️ No Brotli module
✅ CSS · JS gzip
⚠️ No CSS · JS compression
No CSS · JS compression
✅ CSS · JS gzip
→HTML
⚙️ Apache
📝 HTML (WordPress)
🗜️ Brotli · mod_deflate modules
✅ HTML gzip
✅ HTML br
No HTML compression
✅ HTML gzip
When only gzip was requested, Apache compressed the HTML and Nginx compressed the CSS and JS, both with gzip.
When only br was requested, Apache compressed the HTML with br, but the CSS and JS that Nginx serves directly came back as uncompressed originals.
Without an Accept-Encoding header, the HTML, CSS and JS all came back as uncompressed originals.
When gzip and br were sent together, as a browser does, Apache also compressed the HTML with gzip, so all three files came back in gzip.

Gzip compresses (& decompresses) data with the DEFLATE method, while Brotli uses its own format, which adds context modeling to LZ77 and Huffman coding.

Comparing Gzip and Brotli compression
  • Gzip compresses faster than Brotli.
  • Brotli was designed specifically for the web.
  • Brotli offers a better compression ratio (that is, smaller compressed files) at every compression level.
  • Compared with Gzip, Brotli compresses these three file types better: by 21% for HTML, 17% for CSS and 14% for JavaScript.

More and more web servers prefer Brotli over Gzip. Because Brotli is designed to compress streams on the fly, its overall front-end decompression is said to be up to 64% faster than Gzip's.

RFC 1952, published in May 1996, explains that the Gzip format uses the DEFLATE compression method and includes a CRC value for detecting data corruption. The CRC-32 value and size of the original data are written at the end of the compressed data.

RFC 7932, published in July 2016, states that Brotli compresses by combining the LZ77 algorithm with Huffman coding. On top of that, it uses the previous two bytes of the uncompressed data as context to select Huffman codes, and instead of repeated strings it can also refer to words in a static dictionary of 122,784 bytes.

The two formats appear in the response header as [Content-Encoding: gzip] and [Content-Encoding: br]. The [br] value was registered as an HTTP content coding in RFC 7932.

ItemGzipBrotli
SpecificationRFC 1952 · May 1996RFC 7932 · July 2016
Compression methodDEFLATE (LZ77 and Huffman coding)LZ77 and Huffman coding · previous-two-byte context · 122,784-byte static dictionary
Response headerContent-Encoding: gzipContent-Encoding: br

5️⃣ Gzip and Brotli Compression Measured: An Nginx + Apache Server

On a WordPress server running Nginx and Apache together, the responses for one post, WordPress's default block CSS file and the jQuery file were compared, changing only the request header. Requests with only gzip in [Accept-Encoding], with only br, and with no header were sent with curl from the same server.

for ae in gzip br ''; do echo == ${ae:-none}; curl -s -o /dev/null -D - -w 'size: %{size_download}\n' -H Accept-Encoding:$ae https://example.com/hello-world/ | grep -i -E '^(content-encoding|size)'; done
== gzip
content-encoding: gzip
size: 21390
== br
content-encoding: br
size: 20190
== none
size: 90833

The HTML of one post was compressed to 21,390 bytes for the gzip request and 20,190 bytes for the br request, and the request without the header got the uncompressed 90,833 bytes. The br response was 1,200 bytes (5.6%) smaller than gzip.

for f in wp-includes/css/dist/block-library/style.min.css wp-includes/js/jquery/jquery.min.js; do for ae in gzip br ''; do echo == ${f##*/} ${ae:-none}; curl -s -o /dev/null -D - -w 'size: %{size_download}\n' -H Accept-Encoding:$ae https://example.com/$f | grep -i -E '^(content-encoding|size)'; done; done
== style.min.css gzip
content-encoding: gzip
size: 19655
== style.min.css br
size: 140829
== style.min.css none
size: 140829
== jquery.min.js gzip
content-encoding: gzip
size: 30633
== jquery.min.js br
size: 87553
== jquery.min.js none
size: 87553

For the gzip request, the CSS file was compressed to 19,655 bytes and the jQuery file to 30,633 bytes. With only br requested or with no header, the server returned the originals of 140,829 bytes and 87,553 bytes as they were, without a [Content-Encoding] header.

nginx -V 2>&1 | grep -c brotli
0
httpd -M 2>/dev/null | grep -E 'brotli|deflate'
 deflate_module (shared)
 brotli_module (shared)

Static files such as CSS and JS are served and compressed by Nginx directly, and since Nginx in this setup has no Brotli module, it compresses only with gzip.

For HTML, WordPress answers the request that Nginx passes to Apache, and Apache compresses it. Apache has both the Brotli module and the [mod_deflate] module, which handles Gzip compression.

for f in hello-world/ wp-includes/css/dist/block-library/style.min.css wp-includes/js/jquery/jquery.min.js; do echo == $f; curl -s -o /dev/null -D - -w 'size: %{size_download}\n' -H 'Accept-Encoding: gzip, deflate, br, zstd' https://example.com/$f | grep -i -E '^(content-encoding|size)'; done
== hello-world/
content-encoding: gzip
size: 21390
== wp-includes/css/dist/block-library/style.min.css
content-encoding: gzip
size: 19655
== wp-includes/js/jquery/jquery.min.js
content-encoding: gzip
size: 30633

Having a Brotli module on the server does not mean the browser receives Brotli-compressed responses. When the request used [gzip, deflate, br, zstd], the same value Edge 155 sends, Apache also compressed the HTML with gzip, and all three files came back in gzip.

Even when br was placed before gzip or marked as preferred, as in [br;q=1.0, gzip;q=0.5], the HTML came back in gzip. When the same post and the two files were opened in Edge, they were all delivered in gzip as well.

📊Response size and time to first byteBytes · median of 40 runs
No compressiongzipbr
One post (HTML)
WordPress response compressed by Apache
022,70845,41668,12590,833
None90,833No compression · 22.7ms
gzip21,390gzip · 26.3ms
br20,190br · 26.5ms
Browser21,390gzip · 25.0ms
Block CSS file
Static file served directly by Nginx
035,20770,414105,622140,829
None140,829No compression · 19.3ms
gzip19,655gzip · 21.0ms
br140,829No compression · 19.8ms
Browser19,655gzip · 21.1ms
jQuery file
Static file served directly by Nginx
021,88843,77665,66587,553
None87,553No compression · 18.6ms
gzip30,633gzip · 18.4ms
br87,553No compression · 19.0ms
Browser30,633gzip · 18.7ms
The figures were measured on October 18, 2026, on a server running Nginx and Apache together.

Time to first byte is the median of curl's [time_starttransfer] values, measured 40 times each with the request order shuffled; each request opened a new connection, so the TLS connection time is included. For HTML, the uncompressed response took 22.7ms, gzip 26.3ms, br 26.5ms and the browser-like request 25.0ms. CSS and JS took 18–21ms with or without compression.

The compression speed of Gzip and Brotli was not measured here but compared using public sources. RFC 7932 states that Brotli compresses with a significantly higher compression ratio than the gzip program and decompresses much faster than current LZMA implementations. In the Brotli repository, Google explains that Brotli is similar in speed to deflate but offers denser compression.

In 2015, Cloudflare tested both methods on 10,655 HTML, CSS and JavaScript files. Brotli at its highest quality produced results 1.19 times smaller on average than zlib at its highest quality, but it compressed at 0.5MB per second, far slower than the 41.9MB of zlib level 9. Brotli level 4 had a compression ratio similar to zlib level 8 and was slightly faster on average overall, but 1.48 times slower when looking only at files smaller than 64KB.

⏱️ Gzip and Brotli Compression Speed (Public Sources)
Explainer diagram
📏 Compare by
🗜️ Gzip(zlib)
Compressed sizezlib highest quality
Level 4 · level 8 speedzlib level 8
Top-level speedzlib level 9 · 41.9MB per second
vs
🗜️ Brotli
Compressed size1.19 times smaller on average
Level 4 · level 8 speedLevel 4 · similar ratio · 1.48 times slower under 64KB
Top-level speedHighest quality · 0.5MB per second
In Cloudflare's test, Brotli at its highest quality produced results 1.19 times smaller on average than zlib at its highest quality. RFC 7932 also states that Brotli compresses with a significantly higher compression ratio than the gzip program.
Brotli level 4 had a compression ratio similar to zlib level 8 and was slightly faster on average overall, but 1.48 times slower when looking only at files smaller than 64KB.
At the highest quality, Brotli compressed 0.5MB per second and zlib level 9 41.9MB per second, so Brotli was far slower.
Sources: Cloudflare blog (October 2015) · RFC 7932 · Google's Brotli repository (public sources, not measured directly)

We have looked at optimizing a website by compressing files such as HTML, CSS and JavaScript. To speed up a website, file compression and Image optimization can be called essential.

🔢 FAQ & Recommended Content

In this setup, the Nginx and Apache configurations exclude images such as PNG, JPEG and WebP from compression. Even when a PNG file was requested with [gzip, deflate, br, zstd], the same value a browser sends, the server returned the original 216,683 bytes without a [Content-Encoding] header.

With --compressed, curl 7.76.1 sends [Accept-Encoding: deflate, gzip, br] and decompresses the response it receives before printing it. When the same post was requested with this option, the server responded with gzip, and the decompressed HTML was 90,833 bytes, the same as the uncompressed response.

The browser decompresses the response according to the [Content-Encoding] value and then uses it. In Edge, the same CSS file arrived as 19,655 bytes and was decompressed to 140,829 bytes, and the jQuery file arrived as 30,633 bytes and was decompressed to 87,553 bytes.

ℹ️ Affiliate Disclosure
This site's content contains affiliate links. When a visitor buys a product or service through one of them, the site receives a commission from the seller. The amount the buyer pays(it goes down during event discounts ↓)does not go up. Posted prices, discounts, and stock reflect the time of writing and may differ, so confirm with the seller before buying. Products are chosen and reviewed by our own standards, and commissions do not affect the order or content of reviews.