Try it on your own data
Every report in this article is in the free plan. One snippet for web and apps, up to 10 sites.
Start freeText compression means sending HTML, CSS, JavaScript, JSON and SVG as gzip or Brotli data that the browser unpacks. On our four sample text files it cut transfer from 536,040 bytes to 142,440 with gzip 6 and 121,929 with Brotli 11. Pick the right file types, set levels on purpose and check headers.
What you will learn
- Compress every text type; WOFF2, PNG and WebP gained 0.3% or less in our test because they are already compressed
- nginx defaults to gzip level 1 and text/html only; on our files level 1 sent 19.5% more bytes than level 6
- Precompress static files at Brotli 11; use Brotli 4–5 or gzip 6 for responses built per request
What does "enable text compression" mean?
It means your server is sending HTML, CSS, JavaScript, JSON or SVG at full size when it could send a compressed copy that the browser unpacks on arrival. The browser lists what it can unpack in the Accept-Encoding request header, the server picks one, and it labels the response with a Content-Encoding header. HTTP semantics, RFC 9110 section 8.4, defines that header; gzip is one registered coding and br, the Brotli format of RFC 7932, is another.
The fix lives in server or CDN configuration, not in your application code. That is the point of this guide: compression is a setting you can get fully right in an afternoon, as long as you pick the right file types, set a level on purpose and check the response headers afterwards. A wrong default or a missing MIME type leaves a large share of the benefit unused even when compression looks switched on.
An exchange on a working server looks like this:
| Direction | Header | Example value |
|---|---|---|
| Request | Accept-Encoding | gzip, deflate, br, zstd |
| Response | Content-Encoding | br |
| Response | Vary | Accept-Encoding |
Vary: Accept-Encoding tells shared caches to keep separate copies for clients that accept different codings. Compression shrinks bytes on the wire; it does not reduce the number of requests, which is a separate job covered in make fewer HTTP requests.
Is "Enable text compression" still a Lighthouse audit?
Not as a standalone audit in current versions. Chrome's Lighthouse 13 announcement (10 October 2025) maps the old uses-text-compression audit, together with the redirect and server response time audits, into the Document request latency insight. You will still meet the old wording in older reports, in plugins and in tools that run earlier versions.
The difference matters when you read a green result:
| Older "Enable text compression" audit | Document request latency insight | |
|---|---|---|
| What is checked for compression | Text-based responses on the page | The main HTML document request |
| Flag rule described in the docs | Skips files under 1.4 KiB or with gzip savings under 10% | Whether the document response was compressed |
| Estimate | Recompresses with gzip | Reports the document as compressed or not |
The old thresholds come from the audit's documentation; the new scope from the Document request latency insight page. The practical rule: a passing document check says nothing about your stylesheets, scripts or JSON responses, so check those yourself using the steps below.
Which files should you compress?
Compress anything that is text underneath. Skip formats that already contain a compression step. To show the difference, we compressed eight files with gzip level 6 and Brotli quality 11: a built article page, a minified site stylesheet, two minified JavaScript libraries (lodash 4.18.1 and the Vue 3.5.42 global build), a WOFF2 font, a PNG, a WebP image and a flat-colour progressive JPEG used as a social card.
| File | Original bytes | gzip 6 | Brotli 11 | Verdict |
|---|---|---|---|---|
| HTML page | 96,142 | 19,330 (−79.9%) | 15,050 (−84.3%) | Compress |
| Stylesheet | 199,128 | 36,124 (−81.9%) | 29,509 (−85.2%) | Compress |
| lodash, minified | 73,234 | 25,871 (−64.7%) | 23,030 (−68.6%) | Compress |
| Vue build, minified | 167,536 | 61,115 (−63.5%) | 54,340 (−67.6%) | Compress |
| WOFF2 font | 48,256 | 48,249 (−0.0%) | 48,260 (4 bytes larger) | Skip |
| WebP image | 41,344 | 41,377 (33 bytes larger) | 41,348 (4 bytes larger) | Skip |
| PNG image | 233,299 | 232,690 (−0.3%) | 232,492 (−0.3%) | Skip |
| Flat-colour JPEG | 47,167 | 30,257 (−35.9%) | 29,868 (−36.7%) | Fix the image instead |
Minified JavaScript still shrinks by about two thirds, so minification does not replace compression. WOFF2 gains nothing because the WOFF 2.0 specification already uses Brotli for the font data. PNG and WebP have their own compression, and running a second pass only spends CPU.
The JPEG is the exception worth understanding. Large areas of one colour leave repeated patterns in the file that a general-purpose compressor can still find. Photographs usually will not behave this way. If gzip cuts a third off one of your images, treat it as a sign the format is wrong for that picture: re-encoding the same card as WebP at quality 80 produced 16,722 bytes, 64.5% smaller than the JPEG and far better than gzipping it. Compare the result by eye, since that re-encode is lossy, and see how to optimize images for web.
Types that belong on the compress list: text/html, text/css, text/plain, text/xml, text/javascript, application/javascript, application/json, application/ld+json, application/xml, application/manifest+json, image/svg+xml and application/wasm.
Gzip vs Brotli: how much do you save?
On the four text files above (536,040 bytes of HTML, CSS and JavaScript), here is the total transfer size and the compression time per setting. Sizes were measured with Node.js 24's built-in zlib and Brotli and matched Python's zlib and the brotli command line tool to within one byte. Times are the sum of the median of 31 runs per file on an Apple M5 Pro laptop; your server will be slower or faster, but the ratios are the useful part.
| Setting | Total bytes | Saved | Compression time | At 5 Mbit/s |
|---|---|---|---|---|
| Uncompressed | 536,040 | 0% | none | 858 ms |
| gzip 1 | 170,265 | 68.2% | about 2 ms | 272 ms |
| gzip 6 | 142,440 | 73.4% | about 7 ms | 228 ms |
| gzip 9 | 141,858 | 73.5% | about 9 ms | 227 ms |
| Brotli 4 | 144,547 | 73.0% | about 3 ms | 231 ms |
| Brotli 5 | 134,959 | 74.8% | about 5 ms | 216 ms |
| Brotli 11 | 121,929 | 77.3% | about 380 ms | 195 ms |
The last column is simple arithmetic (bytes × 8 ÷ 5,000,000) and ignores latency and TCP slow start, so read it as an order of magnitude, not a page load time.
Four things follow from the table:
- Turning compression on at all is most of the win. Even gzip 1 removes 68.2% of the bytes, taking the illustrative transfer from 858 ms to 272 ms.
- gzip 1 to gzip 6 is worth having. Level 1 sends 27,825 more bytes than level 6 for the same files, which is 19.5% extra.
- gzip 6 to gzip 9 is nearly nothing. The gain is 582 bytes, 0.4%.
- Brotli 11 is the smallest but slow. It beats gzip 6 by 20,511 bytes (14.4%) and takes roughly 50 times as long to compress, so it belongs in the build step.
Four text files: bytes sent by setting
total transfer sizeWhich compression level should you set?
Decide by when the compression happens. web.dev's guide to text compression draws the same line: static files compressed ahead of time can use the most aggressive setting, while responses compressed on request do better with middle settings.
| Situation | Setting | Reason |
|---|---|---|
| Static CSS, JS and SVG with hashed file names | Precompress at Brotli 11 and gzip 9 during the build | CPU cost is paid once per deploy |
| HTML or JSON generated per request | Brotli 4 or 5, gzip about 6 as fallback | A few milliseconds per response, most of the saving |
| A very busy or CPU-bound server | Brotli 4 or gzip 4 to 6, then measure | Watch response time and CPU after the change |
| Files below about 1 KB | Leave uncompressed | They fit in a single packet either way and headers add overhead |
Check the defaults before you assume anything. In the nginx gzip module, gzip is off by default, gzip_comp_level defaults to 1, gzip_min_length to 20 bytes, gzip_types to text/html only and gzip_vary is off. In Apache's mod_brotli, BrotliCompressionQuality defaults to 5, and the documentation reserves 11 for cached content.
How do you enable it on nginx, Apache or a CDN?
For nginx, set gzip explicitly, including every text type you serve. text/html is always compressed once gzip is on, so it is not repeated in the list:
gzip on;
gzip_comp_level 6;
gzip_min_length 1024;
gzip_vary on;
gzip_proxied any;
gzip_types text/css text/plain text/xml text/javascript
application/javascript application/json application/ld+json
application/xml application/manifest+json image/svg+xml
application/wasm;
Brotli is not part of the standard nginx build. With the ngx_brotli module compiled or installed:
brotli on;
brotli_comp_level 5;
brotli_static on;
brotli_types text/css text/plain text/xml text/javascript
application/javascript application/json application/ld+json
application/xml application/manifest+json image/svg+xml
application/wasm;
Precompress static files during the build so the server only has to send them:
brotli -q 11 -k dist/app.js # writes dist/app.js.br
gzip -9 -k dist/app.js # writes dist/app.js.gz
brotli_static on serves the .br file. For .gz files you need gzip_static on, from a module that is not built by default (--with-http_gzip_static_module), although many packaged builds include it.
For Apache, use mod_brotli for clients that accept br and mod_deflate for gzip. Both modules send Vary: Accept-Encoding themselves:
<IfModule mod_brotli.c>
BrotliCompressionQuality 5
AddOutputFilterByType BROTLI_COMPRESS text/html text/css text/javascript application/javascript application/json image/svg+xml
</IfModule>
<IfModule mod_deflate.c>
DeflateCompressionLevel 6
AddOutputFilterByType DEFLATE text/html text/css text/javascript application/javascript application/json image/svg+xml
</IfModule>
Behind a CDN, read its documentation before changing the origin. Cloudflare's content compression page, for example, says content to visitors is compressed by default with Zstandard on Free plans, Brotli on Pro and Business and gzip on Enterprise, subject to the browser's Accept-Encoding, and that it requests content from your origin with br, gzip. In that setup the browser-facing result is decided at the edge, and your origin setting mainly affects the origin-to-CDN leg.
| Where it runs | gzip | Brotli | Precompressed files |
|---|---|---|---|
| nginx | Off by default; level 1; only text/html listed | Third-party ngx_brotli; off by default; level 6 | gzip_static and brotli_static |
| Apache 2.4 | mod_deflate; zlib default level | mod_brotli; quality 5 by default | Rewrite rules shown in the mod_brotli docs |
| Cloudflare (to visitors) | Default on Enterprise | Default on Pro and Business; Free defaults to Zstandard | Edge decides; origin is asked for br or gzip |
Defaults as documented on 2026-12-03. Hosting packages often ship their own config, so read the response headers rather than trusting the default.
How do you check that compression is working?
Ask for a specific coding and read the response headers. Run this once per file type, not just for the home page:
curl -s -o /dev/null -D - -H 'Accept-Encoding: br' https://example.com/app.js
curl -s -o /dev/null -D - -H 'Accept-Encoding: gzip' https://example.com/app.js
Then work through this list:
Content-Encodingis present and names the coding you asked for. If the line is missing, the response was sent uncompressed.VaryincludesAccept-Encodingon compressed responses.- Check one URL of each type: an HTML page, a stylesheet, a script, a JSON API response and an SVG.
- Compare sizes in the browser. In the DevTools Network panel, the Size column shows the transferred size; with big request rows turned on, the bottom value is the uncompressed size. If both numbers are about equal for a text file, it was not compressed.
- Add a
Content-Encodingcolumn (right-click the table header, then Response Headers) and sort by it to spot the files without a value.
Why is a file still uncompressed?
Most cases come down to a short list. Match the symptom to the cause:
| Symptom | Likely cause | Fix |
|---|---|---|
| HTML compressed, CSS and JS not | gzip_types left at its text/html default | Add the MIME types |
| Works directly, fails behind a proxy | gzip_proxied is off and the request carries a Via header | Set gzip_proxied for the cases you need |
| One script never compressed | Served with an unexpected Content-Type | Fix the MIME mapping or add that type |
| Small files uncompressed | Below the minimum length | Expected; leave it |
| Some visitors get the wrong coding from a cache | Missing Vary: Accept-Encoding | Turn on gzip_vary or add the header |
| Origin compresses, browser receives something else | The CDN recompresses at the edge | Configure compression at the CDN |
One security note: compressing a response that contains a secret (such as a token) next to text an attacker can influence may leak information through response size, the class of attack known as BREACH. Apache's module documentation warns about it. Static assets are not affected in this way; for sensitive dynamic pages, ask whoever owns application security.
How to see the effect in TapCub
Suppose the sample site above ran with only HTML compressed and you now add the stylesheet and script types. Those four files drop from 536,040 − 96,142 + 19,330 = 459,228 bytes on the wire to 142,440 at gzip 6. TapCub does not inspect response headers or audit compression, so confirm that with curl or DevTools. What TapCub measures is whether real visitors then saw the page sooner.

- Mark the release. In Configuration › Annotations, add a single-day annotation of type Release, such as "Brotli for CSS and JS", so later readers know why the trend moved.
- Read FCP and LCP at P75. Open Monitoring › Performance. Stylesheets and head scripts hold back the first paint, so first contentful paint is the card most likely to respond.
- Check the loading breakdown. It splits a load into backend, network and frontend. The network part is the download of the HTML response, so it reflects HTML compression; slower on-request compression would show in backend time.
- Compare two date ranges on the same page. This report has no previous-period comparison, so note P75 and sample counts for the week before the annotation, then for the week after. Use Breakdown by device, since phones on slow networks gain most from smaller files.
If the numbers barely move, bytes were not the bottleneck; how to speed up a website ranks other fixes, and removing unused JavaScript cuts bytes that compression only shrinks.
FAQ
Is Brotli better than gzip?
For size, usually yes at comparable effort. On our four text files, Brotli 5 produced 134,959 bytes against 142,440 for gzip 6, and compressed faster; Brotli 11 reached 121,929 but needed far more CPU. Serve Brotli to clients that accept br and keep gzip as the fallback for everything else.
Should I compress images with gzip or Brotli?
No for JPEG photographs, PNG and WebP, which already carry their own compression; our PNG shrank by 0.3% and the WebP file grew slightly. SVG is the exception because it is XML text, so compress it. To make raster images smaller, change dimensions, format or quality instead.
How do I know if gzip is enabled on my site?
Request a file with Accept-Encoding: gzip using curl -s -o /dev/null -D - and look for Content-Encoding: gzip in the response. In browser DevTools, compare the transferred and uncompressed sizes in the Network panel. Test CSS, JavaScript and JSON as well as the HTML page.
Does text compression improve Core Web Vitals?
It can help first contentful paint and largest contentful paint when render-blocking CSS, scripts or the HTML itself take a noticeable time to download, especially on slow mobile connections. It does little when images dominate the page weight or when the server is slow to respond. Confirm with field data before and after.
What about Zstandard?
Zstandard is another HTTP content coding, sent as zstd, and some CDNs and browsers support it. Treat it as an addition, not a replacement: check what your server or CDN offers, keep gzip available, and compare sizes and response times on your own files before switching anything.
Sources
Was this article helpful?
We use your answers to fix and expand this page.
Couldn’t send. Please try again in a minute.
Thanks for the feedback. We’ll use it to improve this page.You’ve already sent feedback on this page. Thanks.

Product Analyst
Focuses on event analysis, conversion funnels, and retention, using clear metric definitions and structured analysis to explain product performance.



