Movatterモバイル変換


[0]ホーム

URL:


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

Content-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 HTTPContent-Encodingrepresentation header lists the encodings and the order in which they have been applied to a resource.This lets the recipient know how to decode the data in order to obtain the original content format described in theContent-Type header.Content encoding is mainly used to compress content without losing information about the original media type.

Servers should compress data as much as possible, and should use content encoding where appropriate.Compressing already compressed media types, such as .zip or .jpeg, is usually not appropriate because it can increase the file size.If the original media is already encoded (e.g., as a .zip file), this information is not included in theContent-Encoding header.

When theContent-Encoding header is present, other metadata (e.g.,Content-Length) refer to the encoded form of the data, not the original resource, unless explicitly stated.Content encoding differs toTransfer-Encoding in thatTransfer-Encoding handles how HTTP messages themselves are delivered across the network on ahop-by-hop basis.

Header typeRepresentation header
Forbidden request headerNo

Syntax

http
Content-Encoding: gzipContent-Encoding: compressContent-Encoding: deflateContent-Encoding: brContent-Encoding: zstdContent-Encoding: dcbContent-Encoding: dcz// Multiple, in the order in which they were appliedContent-Encoding: deflate, gzip

Directives

gzip

A format using theLempel-Ziv coding (LZ77), with a 32-bit CRC.This is the original format of the UNIXgzip program.The HTTP/1.1 standard also recommends that the servers supporting this content-encoding should recognizex-gzip as an alias, for compatibility purposes.

compress

A format using theLempel-Ziv-Welch (LZW) algorithm.The value name was taken from the UNIXcompress program, which implemented this algorithm.Like the compress program, which has disappeared from most UNIX distributions, this content-encoding is not used by many browsers today, partly because of a patent issue (it expired in 2003).

deflate

Using thezlib structure (defined inRFC 1950) with thedeflate compression algorithm (defined inRFC 1951).

br

A format using theBrotli algorithm structure (defined inRFC 7932).

zstd

A format using theZstandard algorithm structure (defined inRFC 8878).

dcbExperimental

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

dczExperimental

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

Examples

Compressing with gzip

On the client side, you can advertise a list of compression schemes that will be sent along in an HTTP request. TheAccept-Encoding header is used for negotiating content encoding.

http
Accept-Encoding: gzip, deflate

The server responds with the scheme used, indicated by theContent-Encoding response header.

http
Content-Encoding: gzip

Whether a server uses compression methods requested by the client depends on server configuration and capabilities.

Specifications

Specification
HTTP Semantics
# field.content-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