Accept-CH HTTP Header: Principles, Types, Working Examples

The Accept-CH is an HTTP response header used by the webserver to request other information from web browsers regarding the client’s device, network, and user agent preferences. The Accept-CH HTTP header allows web servers to customize the content they serve by optimizing images and other content for mobile devices or users on low-bandwidth connections. The Accept-CH HTTP response header is only accessible in a secure context (HTTPS). Although an experimental technology, the Accept-CH HTTP header is active and in the “last call” phase. The Accept-CH is limited to chrome-based browsers on desktop and android (such as Google Chrome, Microsoft Edge, Opera, Brave, Vivaldi & Torch). The Accept-CH HTTP header is not available for non-chrome-based browsers (such as Mozilla Firefox, Safari, w3m, Microsoft Internet Explorer, and Servo). Web browser compatibility must be carefully checked before applying the Accept-CH HTTP header. A web server sets the Accept-CH header to determine which client hints are required to include in a request. Client hints is a cluster of HTTP request header fields that a web server requests from a client to obtain other information (such as screen density, viewport size, and internet connection speed).

What are the principles of Accept-CH HTTP Header?

The principles of the Accept-CH HTTP header are the functions it provides for the webserver to request the user agent information from the client. The web server will deliver the required resources to the web browser based on the received data. Through the use of the Accept-CH HTTP header, client hints modify performance concerns by ensuring that user agents will only send the request headers when required. They are modified with privacy concerns of passive fingerprinting by requiring explicit opt-in and disclosure of required headers by the server.

What is the Syntax of Accept-CH HTTP Header?

The syntax of the Accept-CH HTTP response header is below.

Accept-CH: <list of client hints>

An example of the Accept-CH HTTP response header is shown below for multiple client hints used. In this example, we have the Viewport-Width and Width as the client hints.

Accept-CH: Viewport-Width, Width

What are the directives of the Accept-CH HTTP Header?

The directives of the Accept-CH HTTP response header on sending a request are demonstrated below.

  • <Viewport-Width> provides information about the width of the client’s screen.
  • <Width> provides information about how wide the requested resources’ width should be.
  • <DPR> provides information about the client’s screen density.
  • <Device-Memory> provides information about the client’s RAM size.
  • <Downlink> provides information about the client’s bandwidth.

The Accept-CH-related HTTP response header is the Vary HTTP response header. The Accept-CH HTTP header supports the web server on the client information request, while the Vary HTTP Header ensures that the user agent information undergoes a compress-algorithm before it is sent to the web browser.

Examples of Accept-CH HTTP Header Use.

An example of the Accept-CH HTTP response header is when there’s a client request sent to the webserver with no client hints included. The syntax format of the given example is shown below.

A client request was sent to the webserver with no client hints included.

https://sample_site.com/index.html

The Accept-CH HTTP header below will be sent to the client as a response.

<Accept-CH: Viewport-Width> 
<Accept-CH: Width> 
<Accept-CH: DPR, Device-Memory, Downlink> 

On the example given for the Accept-CH HTTP header, the web server requires the client screen’s width, requested resources’ desired width, client’s RAM, screen density, and bandwidth.

What is the relation between the Accept-CH HTTP Header and the Vary HTTP Header?

The relationship between the Accept-CH HTTP response header and Vary HTTP response header is the function of each header to provide the user agent information to the web browser from the client. When a web server requests the user agent information from the client by using the Accept-CH HTTP header, the client hints are forwarded to the web browser after the webserver uses the Vary HTTP header to determine the HTTP request headers to be used and ensure to decrease the response time and network bandwidth consumption used and ensure to reduce the uncompressed files to decrease the response time and network bandwidth consumption.

Koray Tuğberk GÜBÜR

Leave a Comment

Accept-CH HTTP Header: Principles, Types, Working Examples

by Koray Tuğberk GÜBÜR time to read: 3 min
0