How to check if brotli is enabled
Name the encoding yourself: curl -s -H 'accept-encoding: br' -D - -o /dev/null https://example.com/. A content-encoding: br line means brotli is on. A server sends brotli only to a client that lists br, and it answers an encoding it does not have by sending the body raw with no header and no error.
Checker offline. Follow the manual steps below, they give the same answer.
Why check this
Brotli is usually turned on at the CDN, not in the application, so it disappears whenever traffic stops going through the CDN: a staging host pointed at the origin, a new subdomain that nobody added to the zone, a purge that exposes an origin configured years ago. Run this per hostname after any infrastructure change. The failure it prevents is a release where the HTML triples in transferred size on production while every lab test on the CDN-fronted staging URL stays green.
Prerequisites
- curl built with brotli. Step 1 confirms it. A curl without brotli cannot request
brsensibly, and the Schannel builds shipped with Windows do not have it. - A URL that returns text. See the MDN Accept-Encoding reference for the token list.
- RFC 7932 defines the brotli format, if you need to cite it in a bug.
Steps
- Step 1.
Confirm your curl can speak brotli before trusting any result.
curl --version | tr ' ' '\n' | grep -E '^(brotli|zstd|libcurl)'libcurl/8.21.0 brotli/1.2.0 zstd/1.5.7 brotli zstdNo
brotliline means the build cannot decodebr. Install a build that has it, or read the header only and skip the byte comparison. - Step 2.
Ask for brotli alone and read the header.
curl -s -H 'accept-encoding: br' -D - -o /dev/null https://www.cloudflare.com/ | grep -i -E '^HTTP|content-encoding|vary'HTTP/2 103 HTTP/2 200 vary: accept-encoding content-encoding: br - Step 3.
Measure the same document three ways and compare the byte counts.
for e in identity gzip br; do curl -s -o /dev/null -H "accept-encoding: $e" -w "$e %{size_download}\n" https://www.cloudflare.com/; doneidentity 1317143 gzip 295028 br 105570Brotli is 2.8 times smaller than gzip here and 12.5 times smaller than the raw body.
- Step 4.
Ask for an encoding the server does not have, and watch the silence.
curl -s -H 'accept-encoding: zstd' -D - -o /dev/null -w 'size=%{size_download}\n' https://www.cloudflare.com/ | grep -i -E '^HTTP|content-encoding|size='HTTP/2 103 HTTP/2 200 size=1317143No header, no
406, the full raw body. This is why a brotli check that reads only the status code proves nothing. - Step 5.
Separate the server rule from the browser rule by asking over plain HTTP.
curl -s -H 'accept-encoding: br' -D - -o /dev/null -w 'size=%{size_download}\n' http://example.com/ | grep -i -E '^HTTP|Content-Encoding|size='HTTP/1.1 200 OK Content-Encoding: br size=318The server compressed over an insecure origin. The HTTPS rule is a client rule: Chrome and Firefox list
brinAccept-Encodingonly on secure origins, so the same page in a browser overhttp://arrives gzipped or raw.
How to read the result
| What you see | What it means | What to do |
| --- | --- | --- |
| content-encoding: br | Brotli is on for this route | Record the byte count as the baseline for the next release. |
| content-encoding: gzip after asking for br only | The server ignored your list | Rare and worth a bug. A server may only use an encoding the client offered. |
| No header, full-size body | Brotli is not configured here | Check gzip next. A host with neither is the real defect. |
| Brotli on HTML, none on JS or CSS | The type list is incomplete | Static assets are where brotli pays most. Extend the list at the CDN. |
| Brotli over HTTPS, gzip in a browser over HTTP | Working as designed | Test the scheme users get. An http staging URL understates the saving. |
Common mistakes
Thresholds
What to check next
- How to check if gzip is enabled: the fallback every client gets, including the ones that never send br.
- How to check content-encoding: what the header means when it is absent, and how to read a compression ratio.
- How to check vary header: brotli plus a missing Vary is how a cache hands br bytes to a gzip-only client.
- How to check HTTP response headers with curl: the general header-reading form behind these commands.
- Gzip compression test: runs gzip and brotli against a URL and prints both sizes.
FAQ
How to test brotli compression?
Send accept-encoding: br, read content-encoding, then compare %{size_download} against an identity request. Two requests give the answer and the saving. Confirm your curl has brotli first, as in step 1.
How to check if a response is brotli compressed?
Read content-encoding: br on the response. If you saved the body, the first two bytes are not a reliable signal, because brotli has no magic number the way gzip has 1f 8b. Trust the header.
Does brotli require HTTPS?
The server does not require it. http://example.com/ returned Content-Encoding: br when curl asked. Browsers do restrict it: they list br only on secure origins, so testing over http understates what real users receive.
Why does the site show gzip in Chrome and brotli in curl?
Chrome sends its own Accept-Encoding list, and over an insecure origin that list has no br. Your curl command asked for br explicitly. Compare like for like by matching the header the browser sent.
Verified
Verified by Maks Vernycurl 8.21.0
Each output block is what the command above it printed on that date, on the host named in the step. Figures read from a live site move between runs. Compare the shape of the answer rather than the digits, and see the methodology for how a page is re-verified.
Related on this site
- Checker: compression content-encoding per resource type, size before and after
- Web performance checklist
- All performance and delivery checks
basic5 minpublished updated Maks Verny