When a browser requests a page, it tells the server which compression formats it can decode. If the server ignores that and sends plain, uncompressed HTML, every visitor downloads more bytes than necessary, on every page view. HTML, CSS, JavaScript, JSON and SVG are repetitive text and usually compress very well. Turning on gzip or Brotli is one of the cheapest performance fixes available.
This guide explains the Sitelemetry finding delivery.compression.missing. It covers how the Accept-Encoding and Content-Encoding headers negotiate a format, how to enable gzip and Brotli on Nginx, Apache, IIS, Node.js and common CDNs, and why Vary: Accept-Encoding matters for caches. It ends with how to verify the result with curl and browser DevTools. All examples use example.com.
The short version: let the layer closest to the visitor do the compression, usually the CDN or reverse proxy. Compress text types only, send Vary: Accept-Encoding, and test with a request that actually sends Accept-Encoding. A bare curl request does not send that header, so it will always show an uncompressed response.
Scope of this guide
This guide covers compression of text responses on servers and CDNs you control. Sitelemetry's check reads the Content-Encoding header of one home page response from outside. It does not test every page, asset or client, and it is not a pentest or a performance guarantee.
1. What the finding means
The finding delivery.compression.missing is titled “No compression on the HTML response”. It means Sitelemetry requested the home page of the origin you scanned and got a response whose Content-Type contains text/html, with no Content-Encoding header naming a compression format. The evidence line reads: “No content-encoding header present (gzip/br not observed).”
It is rated low severity. Nothing is exposed and nothing is broken: the page is just heavier on the wire than it needs to be. It is reported with medium confidence. The result comes from a single response seen from one vantage point, and CDN variants, edge rules or bot handling can make what a scanner receives differ from what browsers receive. Treat it as a strong hint and confirm it with the commands in section 10.
The usual causes are mundane:
- Compression was never enabled. The built-in default in nginx is
gzip off, although many distribution packages turn it on in their defaultnginx.conf. On Apache,mod_deflatemay be loaded with no filter configured. - A missing component. On IIS, the Dynamic Content Compression role service is not installed by default, so HTML generated by ASP.NET leaves uncompressed.
- A proxy that skips proxied requests. nginx does not compress requests that arrive through another proxy unless
gzip_proxiedallows it. - A CDN setting. Compression is disabled on the zone or cache behaviour, or the cache policy strips
Accept-Encoding. - An origin header that forbids it.
Cache-Control: no-transformasks intermediaries not to modify the content, and CDNs generally treat that as “do not compress”.
2. How Accept-Encoding and Content-Encoding negotiate
RFC 9110 defines two headers for content coding. The client lists what it can decode in Accept-Encoding, optionally with preference weights. The server picks one format, compresses the body and names the format in Content-Encoding, so the client knows how to decode it:
GET / HTTP/2
Host: example.com
Accept-Encoding: gzip, deflate, br, zstd
HTTP/2 200
content-type: text/html; charset=utf-8
content-encoding: br
vary: Accept-EncodingIf the request has no Accept-Encoding header, or none of the listed formats is available, the server sends the body uncompressed (the identity coding) and omits Content-Encoding. Content coding belongs to the representation itself, end to end. It is different from the hop-by-hop Transfer-Encoding of HTTP/1.1, which HTTP/2 and HTTP/3 do not use for compression.
| Token | Format | Practical notes |
|---|---|---|
gzip | DEFLATE in the gzip container | Supported by essentially every HTTP client; the safe fallback |
br | Brotli, RFC 7932 | Supported by current major browsers, which typically advertise it only on HTTPS connections; usually smaller than gzip for text |
zstd | Zstandard | Advertised by recent Chrome and Firefox versions; optional, and not needed to clear this finding |
deflate | zlib-wrapped DEFLATE | Historically implemented inconsistently; prefer gzip |
identity | No coding | What you get when nothing matches; never sent as a Content-Encoding value in practice |
The MDN Accept-Encoding reference explains quality values such as br;q=1.0, gzip;q=0.8. In practice, servers apply their own preference among the formats the client accepts, usually Brotli first and then gzip.
3. Why compressing HTML matters, and what not to compress
The HTML document is the first request of every page view. The browser cannot discover your stylesheets, scripts and hero image until it has received and started parsing that HTML. Fewer bytes on the critical path help most where it hurts most: slow mobile networks, high-latency links and metered data plans. TCP and QUIC start each connection with a limited sending window, so a smaller document needs fewer round trips to arrive. Lighthouse reports it in its “Document request latency” insight (called “Enable text compression” before Lighthouse 13).
Compression also reduces your egress bandwidth, and it costs little CPU at moderate levels. It does not change what the page contains or how it renders.
Compress text formats:
text/html,text/css,text/plain,text/xmlapplication/javascript(and the legacytext/javascript),application/json,application/xml,application/manifest+jsonimage/svg+xml, which is XML text despite the image type
Do not recompress formats that are already compressed: JPEG, PNG, WebP, AVIF, GIF, MP4, WOFF2 fonts, ZIP and PDF files in most cases. You spend CPU and gain nothing, and the result can even be slightly larger. Most servers also skip very small responses, because compression overhead outweighs the saving on a few dozen bytes.
On levels: gzip runs from 1 to 9 and Brotli from 0 to 11. For responses compressed on the fly, a middle setting (around 4 to 6) is a common balance between CPU and size. For static build output you can precompress once at the highest level and serve the stored file.
4. Enabling gzip and Brotli on Nginx
The gzip module is built into nginx. Put this in the http block (or a file included from it, such as /etc/nginx/conf.d/compression.conf):
gzip on;
gzip_comp_level 5;
gzip_min_length 256;
gzip_vary on;
gzip_proxied any;
gzip_types text/css text/plain text/xml
application/javascript application/json application/xml
application/manifest+json image/svg+xml;text/htmlis always compressed oncegzip onis set. Adding it togzip_typesproduces a “duplicate MIME type” warning.gzip_proxieddefaults tooff, which disables compression for requests carrying aViaheader, that is, requests arriving through another proxy or CDN. Set it toanyif nginx sits behind one.gzip_vary onaddsVary: Accept-Encoding(see section 9).- nginx does not compress a response that already has
Content-Encoding, so an upstream app that compresses on its own will not be compressed twice.
Brotli is not part of open-source nginx. The common option is Google's open-source ngx_brotli module, which some distributions package and which you can otherwise build as a dynamic module matching your exact nginx version. Load it at the top of nginx.conf, then configure it next to gzip:
load_module modules/ngx_http_brotli_filter_module.so;
load_module modules/ngx_http_brotli_static_module.so;
http {
brotli on;
brotli_comp_level 5;
brotli_types text/css text/plain text/xml
application/javascript application/json application/xml
application/manifest+json image/svg+xml;
# optional: serve prebuilt .br files next to the originals
brotli_static on;
}As with gzip, the module's documentation says text/html is always included. Keep the gzip block as the fallback for clients that do not accept br. Then check the configuration and reload:
sudo nginx -t && sudo systemctl reload nginxOne side effect to know about: when nginx compresses a response, it turns a strong ETag into a weak one (W/"..."), because the bytes differ from the uncompressed original. Conditional requests still work.
5. Enabling compression on Apache HTTP Server
Apache uses mod_deflate for gzip and mod_brotli (available since 2.4.26) for Brotli. Both work as output filters. On Debian and Ubuntu, enable them first:
sudo a2enmod deflate brotli
sudo apachectl configtest && sudo systemctl reload apache2Then attach the filters to text types in the virtual host or server configuration:
<IfModule mod_brotli.c>
AddOutputFilterByType BROTLI_COMPRESS text/html text/plain text/css text/xml \
application/javascript application/json application/xml image/svg+xml
</IfModule>
<IfModule mod_deflate.c>
AddOutputFilterByType DEFLATE text/html text/plain text/css text/xml \
application/javascript application/json application/xml image/svg+xml
</IfModule>Each filter compresses only when the request's Accept-Encoding allows its format. With both modules enabled, use curl (section 10) to confirm that a client accepting both gets br and a client accepting only gzip gets gzip. Adjust the filter order if the result is not what you intend.
- Shared hosting: the same directives work in
.htaccessif the host allowsAllowOverride FileInfoand has the modules loaded. If they have no effect, ask the host or use the hosting panel's compression switch. - ETags: mod_deflate by default appends a suffix such as
-gzipto theETagof compressed responses, so caches do not confuse the two representations. TheDeflateAlterETagdirective controls this. - PHP and other backends: output from PHP-FPM, mod_php or a proxied app passes through the same filters, so dynamic HTML is covered as long as its type matches.
6. Enabling compression on IIS
IIS has two kinds of compression, both described in the httpCompression reference. Static compression covers files on disk. Dynamic compression covers generated responses, which includes HTML from ASP.NET, ASP.NET Core behind IIS, and PHP. The finding concerns HTML, so dynamic compression is usually what is missing. Its role service is not installed by default:
Install-WindowsFeature Web-Stat-Compression, Web-Dyn-CompressionThen enable both for the site, in IIS Manager under Compression or in web.config:
<configuration>
<system.webServer>
<urlCompression doStaticCompression="true" doDynamicCompression="true" />
</system.webServer>
</configuration>The MIME types to compress live in the dynamicTypes and staticTypes lists of the server-level httpCompression section, and text/* is in the default list. Add application/json or image/svg+xml there if they are missing.
Two IIS behaviours confuse testing:
- By default, static files are compressed only once they are requested frequently. A single test request may come back uncompressed, and a repeat shortly afterwards compressed.
- IIS can pause dynamic compression when CPU usage is high, so results can vary under load.
For Brotli, Microsoft publishes the IIS Compression extension, which registers a Brotli scheme alongside an improved gzip scheme. Install it, then confirm with curl that br is returned for a client that accepts it.
7. Node.js and application frameworks
If a reverse proxy or CDN already sits in front of your Node app, compress there and keep the app simple. Compressing in Node itself uses CPU on the same event loop that serves requests. When the app faces the internet directly, use the framework's middleware.
Express with the compression package:
const express = require('express');
const compression = require('compression');
const app = express();
app.use(compression()); // register before your routes and static handlers
app.use(express.static('public'));The middleware negotiates from Accept-Encoding, sets Vary, skips small bodies below its threshold, and supports gzip and deflate. Recent releases also add Brotli, so check the README of the version you install. For responses that stream over time, such as server-sent events, call res.flush() after each chunk, or exclude that route with the filter option, so data is not held back in the compression buffer.
Fastify has @fastify/compress, which supports Brotli and gzip. Register it before your routes.
Next.js compresses rendered content and static files with gzip by default when you run next start. If nginx or a CDN compresses in front of it, set compress: false in next.config.js so the work happens once, at the proxy. Node's built-in zlib module also provides createBrotliCompress() if you build a custom server, but a maintained middleware handles negotiation and edge cases for you.
8. CDNs, load balancers and the layer in between
On a CDN-fronted site, what visitors receive is decided at the edge, not at your origin. Check that layer first.
- Cloudflare compresses eligible text content types with gzip or Brotli for clients that accept them. If HTML arrives uncompressed through Cloudflare, look for a rule that changes compression settings, and for
Cache-Control: no-transformfrom the origin. - Amazon CloudFront compresses only when the cache behaviour has Compress objects automatically enabled. The attached cache policy must also include gzip and Brotli in its compression support settings, which also adds the normalized encoding to the cache key. CloudFront compresses objects between 1,000 and 10,000,000 bytes, only when the viewer sends
Accept-Encoding, and leaves responses that the origin already encoded as they are. - Other CDNs and load balancers usually expose a compression toggle per service or route, and some pass through whatever the origin sends. If yours does not compress at the edge, enable compression at the origin and make sure the CDN forwards
Accept-Encodingand stores separate variants.
Edge cases worth checking:
- Two compressors in a chain. If the origin compresses and the proxy compresses again, clients receive garbage. Well-behaved software skips responses that already have
Content-Encoding, but custom middleware sometimes does not. Pick one layer. - Headers stripped on the way. A load balancer or WAF that removes
Accept-Encodingfrom requests makes the origin send identity responses forever. - An origin that serves gzip while the edge offers Brotli. This is fine. Verify at the public hostname, because that is what visitors and Sitelemetry see.
9. Vary: Accept-Encoding, caching and security edge cases
Once compression depends on a request header, a shared cache must know about it. Otherwise it may store the Brotli version and hand it to a client that only understands gzip, or keep serving the uncompressed copy to everyone. Vary: Accept-Encoding tells caches to keep separate entries per accepted encoding:
content-encoding: br
vary: Accept-Encoding- Send it on compressible responses whether or not the current response is compressed, so the cache key is consistent. nginx does this with
gzip_vary on; mod_deflate and the Express middleware add it themselves. - If your application already sends
Vary: Cookieor similar, the values combine into one header (Vary: Accept-Encoding, Cookie). Check that one layer does not overwrite another'sVary. - Many CDNs normalize
Accept-Encodinginto a few buckets, so the number of stored variants stays small.
BREACH and secrets in compressed pages. BREACH is a known class of attack on HTTPS responses that are compressed and contain both a secret, such as a CSRF token, and attacker-influenced reflected input. The usual mitigations are applied per response: mask or rotate tokens on every response (many frameworks do this for CSRF tokens), avoid reflecting request input next to secrets, and add rate limits on sensitive endpoints. Turning off compression for the whole site is rarely the right trade. If you have a page that matches the risky pattern, review that page specifically.
Streaming and HEAD. Some servers omit Content-Encoding on HEAD responses, or buffer streamed responses differently. That is why the verification below uses GET.
10. How to verify the fix with curl and DevTools
curl sends no Accept-Encoding header unless you ask, so a bare curl -I https://example.com/ will always show an uncompressed response. Send the header explicitly, use GET, and discard the body:
# Brotli preferred, gzip accepted, like a modern browser
curl -sS -o /dev/null -D - -H "Accept-Encoding: br, gzip" https://example.com/
# gzip only, to check the fallback
curl -sS -o /dev/null -D - -H "Accept-Encoding: gzip" https://example.com/
# compare bytes on the wire: identity vs Brotli
curl -sS -o /dev/null -w "%{size_download}\n" https://example.com/
curl -sS -o /dev/null -w "%{size_download}\n" -H "Accept-Encoding: br" https://example.com/Without --compressed, curl does not decode the body, so size_download is the transferred size. On Windows, call curl.exe and use -o NUL. Repeat the test for a CSS file, a JavaScript bundle and a JSON endpoint, not only the home page.
| What you see (request sent Accept-Encoding: br, gzip) | What it means | Next step |
|---|---|---|
content-encoding: br and vary: Accept-Encoding | Brotli is on and caches key on the encoding | Nothing; spot-check CSS and JS |
content-encoding: gzip | Compression works; Brotli not offered | Optional: add Brotli at the edge or proxy |
No content-encoding, content-type: text/html | The situation behind delivery.compression.missing | Sections 4 to 8 for your stack; test origin and edge separately |
| Compressed at the origin, uncompressed at the public hostname | The CDN or proxy decodes or bypasses | Check the edge compression setting and the forwarding of Accept-Encoding |
content-encoding present, no vary | Shared caches may serve the wrong variant | Enable gzip_vary or add Vary: Accept-Encoding |
cache-control: no-transform | Intermediaries are asked not to modify content | Remove it unless you need it, or compress at the origin |
To test the origin behind a CDN, use --resolve example.com:443:ORIGIN_IP so the request bypasses the edge but keeps the right hostname and certificate. In Chrome or Firefox DevTools, open the Network panel, reload, select the document and read content-encoding under Response Headers. The size column shows the transferred size next to the decoded resource size.
11. What Sitelemetry checks for compression
The compression check is part of Sitelemetry's transport-delivery module. It sends one GET request to the home page of the origin you enter, following redirects and advertising Accept-Encoding: gzip, deflate, br, and looks at the Content-Encoding header of that response:
- If the header names a compression format the check recognizes, such as gzip or Brotli, it records an unscored observation, “Response compression enabled”, with the observed encoding as evidence. The advice is to keep the configuration and prefer Brotli for critical text assets.
- If no recognized encoding is present and the
Content-Typecontainstext/html, it reportsdelivery.compression.missing, rated low with medium confidence, with the evidence “No content-encoding header present (gzip/br not observed)”. - If the response is neither encoded nor HTML, it reports no compression finding.
- If the home page cannot be reached, returns a non-2xx status or answers with a WAF or CDN bot challenge, the module reports that the probe could not complete and gives no compression verdict. For a challenge, the remediation is to allow authorized scanner traffic in the WAF or CDN policy, or to rerun from an allowlisted source IP.
Limits: it judges one response, the home page HTML document. It does not test your CSS, JavaScript or fonts, the presence of Vary, your compression level, or what other clients would receive. The same module also reads Cache-Control and validators for its caching results. It is a passive header check, not a pentest.
It runs in the free Launch Readiness Snapshot, whose delivery module covers compression, caching and CDN, on any public site without signup. In account audits it is included in the Professional ($149/month) and Enterprise ($249/month) plans. Account security audits also run checks that require ownership verification, so they need a verified target; the snapshot does not. It is not included in the Free plan, but a Free account can run one security audit at Professional depth, which includes this check, with a security audit credit and a verified target; every Free account starts with one audit credit per audit area. See pricing for plan details. The Cache-Control guide covers the caching results from the same module, and the website launch security checklist includes compression and caching in its pre-launch checks.
Common questions
Should I enable gzip or Brotli?
Both. Serve Brotli to clients whose Accept-Encoding includes br, which covers current browsers on HTTPS. Keep gzip as the fallback for everything else. The server picks the best format each client accepts, so enabling both costs nothing in compatibility.
Why does curl show no Content-Encoding even though compression is enabled?
curl sends no Accept-Encoding header by default, so the server correctly replies uncompressed. Add -H "Accept-Encoding: br, gzip" or use --compressed, and use a GET request rather than -I, because some servers omit the header on HEAD responses.
Do I need Vary: Accept-Encoding?
Yes, whenever compression depends on the request header and a shared cache or CDN may store the response. Without it, a cache can serve a Brotli body to a client that only accepts gzip, or keep serving the uncompressed copy. nginx adds it with gzip_vary on, and most middleware adds it automatically.
Should I compress images, fonts and videos?
No for formats that are already compressed, such as JPEG, PNG, WebP, AVIF, MP4 and WOFF2. Compressing them again wastes CPU and can make them slightly larger. SVG is XML text and does benefit, so include image/svg+xml in your compressed types.
Is it safe to compress HTML on HTTPS pages?
For almost all pages, yes. The known risk, BREACH, needs a compressed response that contains a secret together with reflected attacker-influenced input. Mitigate it on the affected pages by masking or rotating tokens per response and not reflecting input next to secrets, rather than disabling compression site-wide.
Sources & further reading
- RFC 9110: HTTP Semantics (Content-Encoding, Accept-Encoding, Vary)www.rfc-editor.org
- RFC 7932: Brotli Compressed Data Formatwww.rfc-editor.org
- MDN: Content-Encoding headerdeveloper.mozilla.org
- MDN: Accept-Encoding headerdeveloper.mozilla.org
- MDN: Vary headerdeveloper.mozilla.org
- nginx: ngx_http_gzip_modulenginx.org
- Apache HTTP Server: mod_deflatehttpd.apache.org
- Microsoft Learn: IIS HTTP Compression (httpCompression)learn.microsoft.com
Prepared by the Sitelemetry editorial team. Explore the linked sources for further detail.



