Lorixen.
EN

Text compression: is your server sending files zipped?

Short answer: Text files such as HTML, CSS, JavaScript, JSON and SVG should travel from your server compressed, usually with Brotli or Gzip, which makes them much smaller and faster to download. You can check in under a minute: open your browser's developer tools, look at a file's response headers and find content-encoding: br or gzip. If it's missing, the cause is usually a server setting, a CDN that isn't in front of the site, or a plugin bypassing compression. The fix is normally a switch in your hosting panel, CDN or server configuration.

Most modern hosting compresses text automatically. But not all, and not always for every file type. When it doesn't, speed tests flag it, and visitors on slow mobile connections wait for files several times larger than necessary. This guide works from symptom to cause to fix.

How compression works, briefly

When a browser requests a file, it tells the server which compression formats it understands using the Accept-Encoding header, for example gzip, deflate, br. If the server compresses the response, it says which format it used in the Content-Encoding header. MDN's reference lists common values including gzip, deflate, br (Brotli) and zstd (Zstandard), and notes that whether a server uses the formats a client asks for depends on the server's configuration and capabilities.

Chrome's Lighthouse documentation recommends Brotli where the browser supports it, because it usually reduces file sizes more than other formats, with Gzip as the fallback.

Symptom 1: Lighthouse or PageSpeed flags "Enable text compression"

What it means: Lighthouse looked at text-based responses without a br, gzip or deflate content-encoding header and calculated what Gzip compression would save. According to the documentation, it doesn't flag responses smaller than 1.4 KiB, or where the saving would be under 10%. So if it's flagged, the saving is real. Recent versions of Lighthouse have moved this check into a broader document request latency insight, so the wording you see may differ.

How to confirm: open Chrome DevTools (Control+Shift+J, or Command+Option+J on a Mac), go to the Network tab, reload the page, click the main document or a CSS/JS file, open Headers, and look for content-encoding under Response Headers. Lighthouse's documentation describes exactly this check.

Symptom 2: The HTML is compressed but CSS, JavaScript or fonts aren't

Likely cause: compression is configured only for certain file types. Older server configurations often list a handful of types (like text/html) and miss others such as application/javascript, application/json, image/svg+xml or text/css.

Fix: extend the list of compressed content types in your server or hosting settings. Don't compress formats that are already compressed, such as JPEG, PNG, WebP, MP4 or WOFF2 fonts; it wastes processing time for little or no gain.

Symptom 3: Compression disappears after adding a plugin or proxy

Likely cause: a caching or optimisation plugin serves pre-built files directly, bypassing the server's compression, or a proxy strips the header. Sometimes two layers both try to compress and one disables the other.

Fix: check the plugin's settings for a compression option and decide on one layer that handles it: the server, the CDN or the plugin. Retest after changing.

Symptom 4: Some visitors get compressed files, others don't

Likely cause: a CDN serves some requests and the origin server serves others directly (for example, a subdomain not routed through the CDN), or cached responses vary.

Fix: make sure all public hostnames pass through the same delivery setup. Many CDNs compress automatically. Cloudflare's documentation, for example, states that it supports Gzip, Brotli and Zstandard compression when delivering content to visitors, returning encoded responses for supported content types when the visitor's browser supports them, and that it also handles compression between itself and your origin.

Symptom 5: Server shows Gzip but not Brotli

Likely cause: Brotli isn't enabled or installed on the server.

Fix: if your host offers Brotli, switch it on; Lighthouse's documentation suggests searching for how to enable Brotli for your specific server software. If not, Gzip is still a large improvement over no compression, and a CDN in front of the site can add Brotli without server changes.

Where to switch it on

  • Managed hosting or website builders: usually automatic. If not, check the control panel or ask support.
  • Shared hosting with cPanel or similar: look for a compression or optimisation setting.
  • Your own server (Apache, Nginx, others): compression is a configuration module; your developer or host can enable it and list the content types.
  • CDN: compression is often on by default. Check that the CDN actually serves your site's main hostname.

After the fix

  1. Recheck the response headers for the HTML, one CSS file and one JavaScript file.
  2. Run Lighthouse or PageSpeed Insights again and confirm the warning is gone.
  3. Look at the transfer size in the Network tab. DevTools shows the transferred (compressed) size alongside the resource size.

A quick example (hypothetical)

A Leeds bakery's site, built years ago on a small virtual server, shows content-encoding: gzip on its HTML but nothing on its stylesheet and scripts. The server's compression rule lists only text/html. Adding the CSS, JavaScript, JSON and SVG content types to that list, then retesting each file in DevTools, clears the Lighthouse warning without any other change.

What compression won't fix

Compression shrinks text files in transit; it doesn't make JavaScript run faster once downloaded, reduce image sizes, or fix slow server response times. If your site is still slow after compression is on, look at large images, heavy third-party scripts and server response time next.

FAQ

Is Brotli always better than Gzip?

For text files it usually compresses more. Browsers that don't support it fall back to Gzip automatically, so serving both is normal.

Can compression break my site?

Rarely. Problems come from double compression or misconfigured proxies. Test after enabling and check that pages load normally.

Should I compress images?

Not with Gzip or Brotli. Images need image-specific optimisation: the right format, dimensions and quality.

Does compression help SEO?

It makes pages faster to load, which helps visitors. Treat it as basic housekeeping rather than a ranking trick.

If your speed report keeps flagging compression and you're not sure which layer should handle it, send us your site address and we'll check the headers and point to the right setting.

Sources

WhatsAppLet’s talk