The Accept-Encoding HTTP request header determines the content compression algorithm that will be accepted. Accept-Encoding HTTP Header is related to Content-Encoding. When data are compressed in Content-Encoding, the Accept HTTP header will inform the browser whether a client can manage the compressed algorithm of the website. Content-Encoding is used for data compression, where representation’s data are compressed without losing the information about the origin media type. Accept-Encoding HTTP request header informs the search engine crawlers and the web browser users if a client can manage the compressed algorithm of the website or not. The advantage of having an Accept-Encoding HTTP header on the webserver is the capability of the header to ensure that the appropriate version of the content is delivered to the web browser. Otherwise, an uncompressed version will be provided to the web browser which may affect the web server’s performance and user experience. Accept-encoding HTTP Header is a part of the content negotiation that affects the response time of the webserver
What are the principles of the Accept-Encoding HTTP Header?
Principles of the Accept-Encoding HTTP Header are the usage of the header to indicate response content-codings are acceptable. Accept-Encoding contributes to a faster loading speed of the webpage by determining the Content-encoding, which is used to compress the data before it is sent to the web browser. When a client wants to access a resource, the client will request it by using a URL. There are 4 different working steps of Accept-Encoding HTTP Header. At the first step, the web server will use the URL and Content negotiation mechanism to choose from the representations. Representations are different forms of a specific resource. At the second step, the web server will then notify the client of the selected representation through a Content-encoding HTTP response header. In the third step, In Content encoding, representation’s data are compressed data without any information loss for the origin media type. Lastly, the Accept-Encoding HTTP request header will inform the browser whether a client can manage the compressed algorithm of the website. A request with no Accept-Encoding HTTP header field indicates no user preferences. Any content coding will be accepted by the user agent unless it is accompanied by a qvalue of 0 (“0” means “not acceptable”).
What is the Syntax of Accept-Encoding HTTP Header?
The syntax shown below demonstrates the appropriate structure and syntax of an Accept-Encoding HTTP request header.
Accept-Encoding: gzip Accept-Encoding: compress Accept-Encoding: deflate Accept-Encoding: brAccept-Encoding: identity Accept-Encoding: *
For Accept-Encoding HTTP request header with multiple algorithms, weighted with the quality value syntax is below.
Accept-Encoding: deflate, gzip;q=1.0, *;q=0.5
Example usage of Accept-Encoding HTTP request header is below.
Accept-Encoding: gzip Accept-Encoding: gzip, compress, br Accept-Encoding: br;q=1.0, gzip;q=0.8, *;q=0.1
What are the directives of the Accept-Encoding HTTP Header?
The directives of the Accept-Encoding HTTP header shown below are compression format that provides individual functions.
- <gzip> gzip uses the LZ77(Lempel-Ziv coding) with a 32-bit CRC.
- <compress> compress uses the LZW (Lempel-Ziv-Welch) algorithm.
- <deflate> deflate uses the zlib structure with the deflate compression algorithm.
- <br> uses the Brotli algorithm.
- <identity> identity, even omitted, is a default value for “acceptable”. The value indicates the identity function which does not require any modification or compression.
- <*> asterisk is a symbol that refers to any value or any content-encoding will be accepted by the user agent.
- <;q=> (qvalues weighting) Any value is placed in an order of preference expressed using a relative quality value called weight.
The Accept-Encoding-related HTTP request headers are Content-Encoding HTTP response header and Content negotiation. The relation of these headers is used for client and server communication. Where the server uses the Content negotiation on selecting the appropriate representation. Content-Encoding will then compress the representation’s data and Accept HTTP header will inform the web browser users if a client can manage the compressed algorithm of the website or not.
Examples of Accept-Encoding HTTP Header Use.
An example of usage for an Accept-Encoding HTTP request header is when the header will need to transfer the appropriate compressed data to the web browser. The format is shown below.
Accept-Encoding: compress, gzip Accept-Encoding: * Accept-Encoding: compress;q=0.5, gzip;q=1.0 Accept-Encoding: gzip;q=1.0, identity; q=0.5, *;q=0
Another example for Accept-Encoding HTTP request header is used for “identity token”, where no encoding is required. The format is shown below.
Accept-Encoding = #( codings [ weight ] ) codings = content-coding / "identity" / "*"
What is the relation between the Accept-Encoding HTTP Header and the Content-Encoding HTTP Header?
The relation between Accept-Encoding HTTP header and Content-Encoding HTTP header is their functions in delivering the appropriate data to the webserver. While Content-Encoding HTTP header provides the compression of data, Accept-Encoding HTTP header will ensure that the appropriate data will be transmitted to the web browser.
- Importance of Keyword Search Volume for SEO - June 29, 2022
- Keyword Difficulty: Definition, Examples, Usage, and Importance for SEO - June 19, 2022
- Google Author Rank: How Google Knows which Content Belongs to Which Author? - May 31, 2022