1001Ferramentas
🗜️Dev

Accept-Encoding Header Parser

Splits an HTTP request header such as gzip, deflate, br;q=1.0 into codings ranked by q value, assuming q=1 whenever the parameter is missing.

Codings

Which compression the client accepts, and in what order

Accept-Encoding is the header through which a browser announces which compressions it can decompress. The server picks one, compresses the response and names its choice back in Content-Encoding. When that negotiation goes wrong the symptom is unmistakable: the browser downloads a binary file instead of showing the page, or the content arrives as gibberish.

Paste the header and the page splits each coding with its q factor, ordering from highest preference to lowest. The same rule as Accept-Language applies: an entry without q counts as 1, and the order they appear in the text is not the order of preference. A q of zero carries its own meaning — it says that coding is not accepted, not that either is fine.

The names that turn up in practice are few. gzip is universal. br, for Brotli, compresses text better and now ships in nearly every browser, but is only offered over HTTPS. zstd is the newest and gaining ground. identity means no compression at all, and the asterisk covers anything not listed. On the server side, any response that varies with this header must send Vary naming it, or an intermediate cache will serve compressed content to someone who never asked for it.

Frequently asked questions

Why does my content arrive uncompressed?
The common causes are the server not having that MIME type on its compressible list, the response being below the configured minimum size, or a proxy along the way having stripped the header. It is also worth checking whether the response already arrives compressed from the origin — compressing twice is usually disabled on purpose.
Is Brotli always better than gzip?
For static text content, generally yes, with gains around 15 to 20 per cent over gzip. For content generated per request, high Brotli levels cost too much CPU and the maths may not work out — the usual practice is a high level for what is pre-compressed at build time and a low one for dynamic responses.
Do I really need Vary?
You do, whenever the response changes with the header. Without Vary naming Accept-Encoding, a shared cache may store the Brotli version and hand it to a client that only understands gzip. The symptom is corrupted content that shows up for some users and disappears on reload.

Related Tools