Gzip or Brotli: which one your visitors get, and why it can differ

Gzip and Brotli are two ways of compressing text (HTML, CSS, JavaScript, JSON) before it travels. Brotli usually gives smaller files; gzip is older and understood by everything. The server chooses, according to what the browser says it can handle, so two different visitors can receive different versions of the same page. There is nothing to configure in your account: compression is on here. This article explains how to see which one was used. To confirm it is on and measure the gain, see compression: confirming it is on.

How the choice is made

1 The browser sends the Accept-Encoding header with the list of what it can unpack, for example gzip, deflate, br.
2 The server picks one and returns the Content-Encoding header saying which: gzip or br.
3 The browser unpacks it. The visitor never sees any of this.

Why they can differ

Situation What happens
Site opened over http (no padlock) Browsers only advertise Brotli over HTTPS. Over http they receive gzip.
Site behind a service such as Cloudflare The service does the compressing, with its own rules. The answer can be br even if the origin server would give gzip.
Very small files Compressing may not be worth it, and the server leaves them out.
Images, video, ZIP, PDF They are already compressed formats. Compressing again gains nothing, and it is not done.
Two plugins compressing They may compress twice or clash. One is enough.

Seeing and comparing, step by step

1 In the browser: F12, Network tab, click the page row and read content-encoding in the response headers.
2 On the command line, ask for each version and compare the bytes received: curl -s -H "Accept-Encoding: gzip" -o /dev/null -w "%{size_download}\n" https://yourdomain.tld/. Repeat swapping gzip for br (and for identity to get the uncompressed size). If your curl build does not support Brotli, it does not matter: the server answers anyway, and curl only counts the bytes.
3 Check there is no clash: if only one of the requests returns content-encoding, the other path is not compressing. Tell us which.
cPanel’s “Optimize Website” screen is not where this is switched on. Changing it does not alter what the server does. It is explained in compression: confirming it is on, and measuring what you gained.
It is not worth arguing gzip against Brotli. On ordinary pages the difference between them is small beside the difference between having compression and not having it, and beside the weight of the images. If your page is heavy, the culprit is almost never the text: see image optimisation and WebP.

Neither request returns content-encoding and the page is text? Send us the exact address and the curl result.

Open a support ticket

SEE ALSO

Compression: confirming it is on, and measuring what you gained

HTTP/2 and HTTP/3: how to see which one your site uses

Browser caching with .htaccess

Hosting plans and what each includes

RECOMMENDED PRODUCT

Web hosting with cPanel

Domain and SSL included, daily backups and the panel you already know. from $6.60/mo (3-year plan, with coupon)

See plans
  • 0 Users Found This Useful
Was this answer helpful?