Content-Encoding Header

Table of Content

The Content-Encoding HTTP header is a crucial component that provides details about how the entity data of a responding message has been encoded. This header is predominantly used for compressing the media-type content of a particular website. It can drastically reduce the amount of data that needs to be transferred over the web, considerably improving the speed and performance of the website.

Syntax

Content-Encoding: gzip
Content-Encoding: compress
Content-Encoding: deflate
Content-Encoding: identity
Content-Encoding: br

Directives

The various directives that may be used for the Content-Encoding HTTP header include:

  • gzip
  • compress
  • deflate
  • identity
  • br (Brotli)

Examples

To use the Content-Encoding header you would encode it into your HTTP as follows:

GET /example HTTP/1.1
Host: www.example.com
Accept-Encoding: gzip, deflate

And a possible response could be:

HTTP/1.1 200 OK
Content-Encoding: gzip

(content here)

Browser Compatibility

Browser Compatibility
Chrome Supported
Firefox Supported
Safari Supported
Opera Supported
Edge Supported

How to modify Content-Encoding header

ModHeader is a Chrome extension that allows you to add, modify, or remove HTTP request headers and can be used to modify the Content-Encoding header.

To use ModHeader to change the Content-Encoding header:

  1. Install ModHeader from the Chrome web store
  2. Click on the ModHeader icon in the toolbar
  3. Click to add a new Profile
  4. Enter "Content-Encoding" into 'Request headers' Name field, and the type of encoding you want into the Value field. For example, gzip.

This can be beneficial in testing the compression of your server to ensure it's functioning optimally. It can also help in experiencing how your website performs under different types of encodings.