Accept-Encoding:gzip and Content-Encoding:gzip

Viewed 19261

What is the difference between the two HTTP headers?

  • Accept-Encoding:gzip
  • Content-Encoding:gzip
2 Answers

Accept-Encoding

To paraphrase IETF internet standard RFC-7231, the Accept-Encoding request header field can be used by user agents to make requests that indicate what response content-codings are acceptable in the response.

The Accept-Encoding header can be quite complex, e.g.

Accept-Encoding: gzip;q=1.0, identity; q=0.5, *;q=0

https://datatracker.ietf.org/doc/html/rfc7231#section-5.3.4

Content-Encoding

The Content-Encoding response header field indicates what content codings have been applied to the response representation. Content-Encoding is primarily used to allow the response entity to be compressed without losing the identity of its underlying media type.

The Content-Encoding value is simple and should be accompanied by a "Vary" header, e.g.

Content-Encoding: gzip
Vary: Accept-Encoding

https://datatracker.ietf.org/doc/html/rfc7231#section-3.1.2.2

Related