Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Accept-Encoding:gzip and Content-Encoding:gzip

What is the difference between the two HTTP headers?

  • Accept-Encoding:gzip
  • Content-Encoding:gzip
like image 656
user8519380 Avatar asked Sep 18 '17 14:09

user8519380


People also ask

What is accept-Encoding gzip?

It means the client can accept a response which has been compressed using the DEFLATE algorithm. https://en.wikipedia.org/wiki/Deflate This algorithm is also used in gzip compression format.

How do I enable gzip content Encoding?

To enable gzip on an Apache web server, add the gzip compression commands inside the mod_deflate module at the end of the . htaccess file.

What does accept-Encoding mean?

The Accept-Encoding request HTTP header indicates the content encoding (usually a compression algorithm) that the client can understand. The server uses content negotiation to select one of the proposals and informs the client of that choice with the Content-Encoding response header.


1 Answers

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

like image 185
Ratul Sharker Avatar answered Oct 06 '22 00:10

Ratul Sharker