Movatterモバイル変換


[0]ホーム

URL:


  1. Web
  2. HTTP
  3. Reference
  4. Headers
  5. Accept-Encoding

Accept-Encoding header

Baseline Widely available *

This feature is well established and works across many devices and browser versions. It’s been available across browsers since ⁨July 2015⁩.

* Some parts of this feature may have varying levels of support.

The HTTPAccept-Encodingrequest andresponse header indicates the content encoding (usually a compression algorithm) that the sender can understand.In requests, the server usescontent negotiation to select one of the encoding proposals from the client and informs the client of that choice with theContent-Encoding response header.In responses, it provides information about which content encodings the server can understand in messages to the requested resource, so that the encoding can be used in subsequent requests to the resource.For example,Accept-Encoding is included in a415 Unsupported Media Type response if a request to a resource (e.g.,PUT) used an unsupported encoding.

Even if both the client and the server support the same compression algorithms, the server may choose not to compress the body of a response if theidentity value is also acceptable.This happens in two common cases:

  1. The data is already compressed, meaning a second round of compression will not reduce the transmitted data size, and may actually increase the size of the content in some cases.This is true for pre-compressed image formats (JPEG, for instance).
  2. The server is overloaded and cannot allocate computing resources to perform the compression. For example, Microsoft recommends not to compress if a server uses more than 80% of its computational power.

As long as theidentity;q=0 or*;q=0 directives do not explicitly forbid theidentity value that means no encoding, the server must never return a406 Not Acceptable error.

Note:IANA maintainsa list of official content encodings.Thebzip andbzip2 encodings are non-standard, but may be used in some cases, particularly for legacy support.

Header typeRequest header,Response header
Forbidden request headerYes

Syntax

http
Accept-Encoding: gzipAccept-Encoding: compressAccept-Encoding: deflateAccept-Encoding: brAccept-Encoding: zstdAccept-Encoding: dcbAccept-Encoding: dczAccept-Encoding: identityAccept-Encoding: *// Multiple algorithms, weighted with the quality value syntax:Accept-Encoding: deflate, gzip;q=1.0, *;q=0.5

Directives

gzip

A compression format that uses theLempel-Ziv coding (LZ77) with a 32-bit CRC.

compress

A compression format that uses theLempel-Ziv-Welch (LZW) algorithm.

deflate

A compression format that uses thezlib structure with thedeflate compression algorithm.

br

A compression format that uses theBrotli algorithm.

zstd

A compression format that uses theZstandard algorithm.

dcbExperimental

A format that uses theDictionary-Compressed Brotli algorithm. SeeCompression Dictionary Transport.

dczExperimental

A format that uses theDictionary-Compressed Zstandard algorithm. SeeCompression Dictionary Transport.

identity

Indicates the identity function (that is, without modification or compression). This value is always considered as acceptable, even if omitted.

* (wildcard)

Matches any content encoding not already listed in the header. This is the default value if the header is not present. This directive does not suggest that any algorithm is supported but indicates that no preference is expressed.

;q= (qvalues weighting)

Any value is placed in an order of preference expressed using a relativequality value calledweight.

Examples

Default Accept-Encoding values

Browser navigation typically has the followingAccept-Encoding request header value:

http
GET /en-US/ HTTP/2Host: developer.mozilla.orgAccept-Encoding: gzip, deflate, br, zstd

Weighted Accept-Encoding values

The following header showsAccept-Encoding preferences using a quality value between0 (lowest priority) and1 (highest-priority).Brotli compression is weighted at1.0, makingbr the client's first choice, followed bygzip at0.8 priority, and then any other content encoding at0.1:

http
Accept-Encoding: br;q=1.0, gzip;q=0.8, *;q=0.1

Specifications

Specification
HTTP Semantics
# field.accept-encoding
Zstandard Compression and the 'application/zstd' Media Type
# name-content-encoding

Browser compatibility

See also

Help improve MDN

Learn how to contribute

This page was last modified on byMDN contributors.


[8]ページ先頭

©2009-2025 Movatter.jp