Movatterモバイル変換


[0]ホーム

URL:


  1. Веб-технологии для разработчиков
  2. HTTP
  3. Reference
  4. Заголовки HTTP
  5. Content-Encoding

This page was translated from English by the community.Learn more and join the MDN Web Docs community.

View in EnglishAlways switch to English

Content-Encoding

Baseline Widely available *

This feature is well established and works across many devices and browser versions. It’s been available across browsers since ⁨июль 2015 г.⁩.

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

Content-Encoding - это сущность заголовка, используемая для сжатия медиа-типа. При наличии её значение определяет кодировку, применённую к сущностиbody. Это позволяет клиенту информацию как декодироватьbody, чтобы получить медиа-тип ссылающийся на заголовокContent-Type

Рекомендация - сжимать данные насколько это возможно и следовательно использовать это поле, но некоторые типы данных, такие как изображения в формате jpeg, уже сжаты. Иногда, использование дополнительного сжатия не уменьшает размер пакета и даже может сделать загрузку дольше.

Header typeEntity header
Forbidden header nameno

Синтаксис

Content-Encoding: gzipContent-Encoding: compressContent-Encoding: deflateContent-Encoding: identityContent-Encoding: br// Multiple, in the order in which they were appliedContent-Encoding: gzip, identityContent-Encoding: deflate, gzip

Директивы

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).

identity

Indicates the identity function (i.e., no compression or modification). This token, except if explicitly specified, is always deemed acceptable.

br

A format using theBrotli algorithm.

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

Note that the server is not obligated to use any compression method. Compression highly depends on server settings and used server modules.

Спецификации

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

Совместимость с браузерами

Смотрите также

Help improve MDN

Learn how to contribute

This page was last modified on byMDN contributors.


[8]ページ先頭

©2009-2025 Movatter.jp