PageSpeed fix guide ·

Enable text compression (Document request latency): how to fix it

Enable text compression means your server sends HTML, CSS or JavaScript at full size instead of compressed. In Lighthouse 13 the check for the page's HTML is part of Document request latency. Switch on Brotli or gzip on the server, in your host's panel or through your cache plugin, for all text files. Browsers unpack them automatically, and nginx's documentation says this often cuts the data sent by half or more.

In PageSpeed Insights
Document request latency
Older name
Enable text compression
In a FlashMax report
Text files travel uncompressed

8.9% of the 40,951 WooCommerce stores FlashMax tested have this problem. See the study

The short fix

  1. Check the content-encoding header of the page and of a CSS and a JS file in Chrome DevTools.
  2. Turn on Brotli or gzip in your hosting panel, your cache plugin or the server config.
  3. Cover all text types: HTML, CSS, JavaScript, JSON, XML and SVG.
  4. Leave images, video and archives alone, because they are already compressed.
  5. Re-test and confirm that every text file shows br or gzip.

What PageSpeed Insights is telling you

Lighthouse 13 merged the old Enable text compression audit into Document request latency, an insight in the Insights list of PageSpeed Insights. For compression, that insight checks only the main HTML document and flags it if the page arrived uncompressed. It also covers server response time and redirects.

The old audit looked at every text file and listed those with real savings: files of at least 1.4 KiB where gzip would save at least 10%. Many tools and guides still use that name.

The FlashMax card Text files travel uncompressed works more like the old audit. It checks your site's own text files, not only the HTML, and appears when compressing them would save more than 10 KB.

Why uncompressed text slows the page

Compression shrinks text before it travels. The browser says which formats it can unpack in the Accept-Encoding request header, and the server names the one it used in the Content-Encoding response header. nginx's documentation says gzip often cuts transferred data by half or more, and Chrome's documentation says Brotli can shrink files further than gzip.

Smaller HTML and CSS arrive sooner, so the browser can start drawing sooner. Uncompressed files mainly delay First Contentful Paint (10% of the Lighthouse score) and Largest Contentful Paint (25%). The extra bytes cost the most on a slow mobile connection, which is what the phone test simulates.

How common it is

In our study of 40,951 WooCommerce stores, 8.9% (3,652 stores) got this card. Their median phone score was 49, against 53 for stores without it. That is a correlation, not proof: stores with one problem usually have others too. Full numbers are in the WooCommerce speed study.

How to find the uncompressed files

The free FlashMax test lists the files behind the card, so you can see whether it's the HTML, the theme's CSS or a plugin's scripts. PageSpeed Insights now reports this for the HTML document only.

To check a file in Chrome DevTools, open the Network panel, reload, click the file and look for content-encoding under Response Headers. A value of br, gzip or zstd means it was compressed; no header means it wasn't. With Big request rows turned on in the Network panel settings, the Size column shows two values: the top one is the transferred size, the bottom one the full size.

From a terminal:

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

Only files from your own domain can be fixed. Scripts from Google, Facebook or chat widgets are compressed, or not, by whoever serves them.

How to fix it on WordPress and WooCommerce

Compression is a web server setting, not a WordPress one; Lighthouse's own WordPress advice is to enable it in the web server configuration. Look in your hosting control panel first, and ask your host if you can't find it.

WP Rocket

On Apache and LiteSpeed servers, WP Rocket adds gzip rules (using mod_deflate) to your .htaccess file on its own. For that, mod_deflate must be enabled on the server. nginx doesn't use .htaccess, so there the rules have to go into the server configuration.

Apache by hand (.htaccess)

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

mod_deflate also sends the Vary: Accept-Encoding header, so caches between you and the visitor keep compressed and plain copies apart.

nginx

# in the http { } or server { } block
gzip on;
gzip_vary on;
gzip_comp_level 5;
gzip_min_length 1000;
gzip_proxied any;
gzip_types text/plain text/css text/xml text/javascript
           application/javascript application/json application/xml
           application/rss+xml image/svg+xml;
# text/html is always compressed once gzip is on

gzip_proxied any matters behind a CDN or proxy: by default nginx doesn't compress responses to requests that arrive through one (requests with a Via header). Brotli on nginx needs the separate ngx_brotli module; once it is loaded, brotli on; and a brotli_types line with the same types switch it on. Run nginx -t before you reload.

Shopify and hand-built sites

Shopify compresses files on its CDN with Brotli and gzip automatically. If the card shows up on a Shopify store, check which domain the listed files come from: files served from other servers, such as an app's, can only be fixed by whoever runs them, or by replacing the app.

Hand-built sites: use the nginx or Apache settings above on whichever server sits in front of your app. Make sure the rule covers CSS and JavaScript, not only HTML; nginx compresses only text/html until you list more types in gzip_types.

Mistakes to avoid

  • Compressing only HTML. nginx's default gzip_types covers only text/html, so CSS and JavaScript stay uncompressed until you add them.
  • Compressing images, video or zip files. They are already compressed, and MDN notes that compressing them again can even make them bigger.
  • Leaving out the Vary header. Without Vary: Accept-Encoding, a cache can hand a compressed file to a client that didn't ask for one. In nginx, gzip_vary on adds it.
  • Editing .htaccess without a copy. A rule for a module the server doesn't have, outside an <IfModule> block, can stop the site from loading. Keep the working file.
  • Chasing third-party files. You can't compress another company's scripts. Remove the ones you don't need.

How to check that it worked

Reload with DevTools open and check content-encoding on the page, a CSS file and a JavaScript file. If the header is still missing, a cache plugin, CDN or proxy may be serving an older copy, so clear its cache. Then re-test with FlashMax or PageSpeed Insights, 2 or 3 times, since lab results vary.

Real-user data in PageSpeed Insights and Search Console covers the last 28 days, so it takes about four weeks to show the change.

Questions people ask

Should I use gzip or Brotli?

Use Brotli where your server or CDN supports it and keep gzip as the fallback, as Chrome's documentation recommends. The browser says which it accepts and the server picks. Either one clears the warning.

Why does PageSpeed Insights still ask for compression after I turned it on?

Check that the change reached the server that actually answers. A cache plugin may serve stored pages, a CDN may serve its own copy, or the rule may cover HTML only. Clear all caches and read content-encoding in DevTools.

Can a WordPress plugin enable compression?

Only on servers that read .htaccess: plugins such as WP Rocket write mod_deflate rules there on Apache and LiteSpeed. On nginx a plugin can't change the server config, so you or your host must add the gzip lines.

Which files should be compressed?

Text formats: HTML, CSS, JavaScript, JSON, XML and SVG. The old Lighthouse audit ignored files under 1.4 KiB and files where gzip saved less than 10%, because the gain there is tiny.

Sources

  1. Document request latency (Chrome for Developers)
  2. Enable text compression (Lighthouse docs, Chrome for Developers)
  3. Content-Encoding header (MDN)
  4. Module ngx_http_gzip_module (nginx.org)
  5. Brotli dynamic module (NGINX Plus documentation)
  6. Apache module mod_deflate (httpd.apache.org)
  7. Enable GZIP compression (WP Rocket documentation)
  8. The Shopify platform (Shopify.dev)

Rather have it done?

The FlashMax team fixes the issues in your report, on a copy first, and shows the before-and-after.

See the speed optimization service

              AMERICANEXPRESSPayPalDISCOVERstripeVISA