Accept-Encoding:gzip and Content-Encoding:gzip

user8519380 picture user8519380 · Sep 18, 2017 · Viewed 14.8k times · Source

What is the difference between the two HTTP headers?

  • Accept-Encoding:gzip
  • Content-Encoding:gzip

Answer

Ratul Sharker picture Ratul Sharker · Sep 18, 2017

Accept-Encoding:

It is a request header. The HTTP client uses this header to tell the server which encoding(s) it supports. The server is allowed to send the response content in any of these encodings.

From MDN

The Accept-Encoding request HTTP header advertises which content encoding, usually a compression algorithm, the client is able to understand. Using content negotiation, the server selects one of the proposals, uses it and informs the client of its choice with the Content-Encoding response header.

Content-Encoding:

It is a response header. The HTTP server uses this header to tell the client which particular encoding the content has actually been encoded in.

From MDN

The Content-Encoding entity header is used to compress the media-type. When present, its value indicates which encodings were applied to the entity-body. It lets the client know, how to decode in order to obtain the media-type referenced by the Content-Type header.

If you want to see them play in action, open Inspect Element in Firefox / Chrome, then check for the Network tab to see them in action. Look for Accept-Encoding in request headers and Content-Encoding in response headers.

Inspect Element in firefox