Performance

Gzip vs Brotli: How to Check and Enable Text Compression

Gzip vs Brotli explained: what text compression does, how to check which one your site sends, and how to enable it on WordPress, Apache, Nginx or Cloudflare.

By Zebra Hosting Cloud

If PageSpeed Insights told you to enable text compression, the fix is usually quick. Gzip and Brotli are two ways a server shrinks text files, such as HTML, CSS and JavaScript, before it sends them. The browser unpacks them when they arrive. Brotli usually makes smaller files than gzip, and every current major browser supports both. This guide shows you how to check what your site sends today, how to turn compression on for WordPress, Apache or Nginx, and what to leave alone.

What text compression does for your pages

Most of a web page starts life as text. Your HTML, your stylesheets and your scripts are full of repeated words, tags and spaces. Compression finds those repeats and writes them in a shorter form. The visitor gets exactly the same page, in fewer bytes.

Think of an online shop in Tirana. A customer opens it on a phone, on mobile data, on the bus home. Smaller files reach that phone sooner and use less of the customer's data plan. If your customers in Kosovo, Albania or North Macedonia shop from their phones, this is an easy speed win.

Compression is for text. Photos, videos and most modern font files are already compressed, so squeezing them again gains almost nothing.

Gzip, Brotli and Zstandard in plain words

MethodWhat it isBrowser support
GzipThe oldest method, in use since the 1990s. The safe fallback.Every browser
BrotliCreated by Google and published as a standard in 2016. Usually smaller text files than gzip.All current major browsers, over HTTPS only
Zstandard (zstd)The newest option on the web. Fast to compress.Current Chrome, Edge and Firefox; Safari 26.3 on the newest Apple systems

You don't have to pick one method for everyone. Each browser sends an Accept-Encoding header, a short line in its request that lists the methods it understands. The server picks one and labels its reply with a content-encoding header. Older browsers simply get gzip.

Check what your site sends right now

In your browser

  1. Open your site in Chrome, Edge or Firefox.
  2. Press F12 to open the developer tools and go to the Network tab.
  3. Reload the page and click the first row, which is your page itself.
  4. Under Headers, find Response Headers and look for content-encoding.

A value of br means Brotli, gzip means gzip and zstd means Zstandard. No line at all means the file was sent uncompressed. Check one CSS file and one JavaScript file too, not only the page.

From the command line

curl -s -o /dev/null -D - -H "Accept-Encoding: br, gzip" https://example.com | grep -i content-encoding

This asks for your page the way a browser would and prints only the compression line. On Windows 10 or 11, type curl.exe in PowerShell, change /dev/null to NUL and grep -i to findstr /i.

In PageSpeed Insights

Older Lighthouse reports showed this as Enable text compression. Since Lighthouse 13, the check is part of the Document request latency insight, which warns you when your main page arrives uncompressed.

Enable compression on WordPress, Apache or Nginx

WordPress

WordPress does not compress pages by itself. Your web server or your CDN does. Many caching plugins have a gzip option that writes rules into your .htaccess file. Check your headers first. If your site is already compressed, leave that option off.

Apache

Where Apache serves your site, you can add these lines to the .htaccess file in your site's main folder. In Plesk, you can edit it with the File Manager. If you are not sure which web server your plan uses, ask support before you change anything.

<IfModule mod_deflate.c>
  AddOutputFilterByType DEFLATE text/html text/plain text/css text/javascript application/javascript application/json image/svg+xml
</IfModule>

On your own server with Apache 2.4.26 or newer, you can add Brotli too. On Ubuntu or Debian, run sudo a2enmod brotli. Then add a copy of the block above the gzip one, with mod_brotli.c and BROTLI_COMPRESS in place of mod_deflate.c and DEFLATE. Restart Apache with sudo systemctl restart apache2 and check the header again.

Nginx

On a VPS, you control the web server yourself. Add these lines inside the http block of /etc/nginx/nginx.conf:

gzip on;
gzip_vary on;
gzip_comp_level 5;
gzip_types text/plain text/css text/javascript application/javascript application/json application/xml image/svg+xml;

Ubuntu and Debian already have a gzip on; line there, plus commented-out gzip lines. Edit those instead of adding copies. HTML is compressed as soon as gzip on is set, so you don't need to list it. Test the file with sudo nginx -t, then run sudo systemctl reload nginx. Brotli in Nginx needs an extra module. On Ubuntu and Debian it is packaged as libnginx-mod-http-brotli-filter. Once it is installed, add brotli on; and a brotli_types line with the same file types.

Compression through a CDN like Cloudflare

A CDN, or content delivery network, keeps copies of your site on servers close to your visitors. Cloudflare compresses text files on their way to the visitor, even when your own server sent them uncompressed.

Which method a visitor gets depends on the Cloudflare plan, its settings and the visitor's browser, so use the header check above to see what actually arrives. Compression on your own server is still worth it, because it makes the trip from your server to the CDN lighter. You can read more about how our Cloudflare CDN works.

Mistakes to avoid: images, double compression and old plugins

  • Compressing images and video. JPEG, PNG, WebP, MP4 and WOFF2 files are already compressed. Keep your list of file types to text.
  • Double compression. If a plugin and the server both compress the same file, the browser may show a broken page or an error such as ERR_CONTENT_DECODING_FAILED. Keep one and turn the other off.
  • Old optimisation plugins. Plugins that are no longer updated, or a PHP setting such as zlib.output_compression, can clash with server compression.
  • The highest compression level. Files compressed on the fly cost more server time at the top level for very little gain. A middle setting is enough.
  • Skipping the test. After every change, check the content-encoding header again.

Fast, compressed delivery with Zebra Hosting

Every site we host sits behind Cloudflare's CDN. Every domain gets a free SSL certificate that renews automatically, which matters here because browsers only accept Brotli over HTTPS. Our servers are in Pristina, close to visitors across the Balkans. If you run WordPress, our WordPress hosting comes with one-click install, automatic updates and Plesk for editing files. And if the header still shows nothing, write to our support team and we'll look at it with you.