Path: blob/main/files/en-us/web/http/headers/critical-ch/index.md
6546 views
------{{HTTPSidebar}}{{SeeCompatTable}}{{SecureContext_Header}}
The Critical-CH client hint response header is used along with {{HttpHeader("Accept-CH")}} to specify that accepted client hints are also critical client hints.
User agents receiving a response with Critical-CH must check if the indicated critical headers were sent in the original request. If not, the user agent will retry the request along with the critical headers rather than render the page. This approach ensures that client preferences set using critical client hints are always used, even if not included in the first request, or following server configuration changes.
Each header listed in the Critical-CH header should also be present in the Accept-CH and Vary headers.
| Header type | {{Glossary("Response header")}} |
|---|---|
| {{Glossary("Forbidden header name")}} | no |
Syntax
Directives
<ch-list>: A list of one or more comma-delimited client hint headers that the server considers to be critical client hints.
Examples
The client makes an initial request to the server:
The server responds, telling the client via {{httpheader("Accept-CH")}} that it accepts {{httpheader("Sec-CH-Prefers-Reduced-Motion")}}. In this example Critical-CH is also used, indicating that Sec-CH-Prefers-Reduced-Motion is considered a critical client hint.
Note: We've also specified
Sec-CH-Prefers-Reduced-Motionin the {{httpheader("Vary")}} header to indicate that responses should be separately cached based on the value of this header (even if the URL stays the same). Each header listed in theCritical-CHheader should also be present in theAccept-CHandVaryheaders.
The client automatically retries the request (due to Critical-CH being specified above), telling the server via Sec-CH-Prefers-Reduced-Motion that it has a user preference for reduced-motion animations:
The client will include the header in subsequent requests in the current session unless the Accept-CH changes in responses to indicate that it is no longer supported by the server.
Specifications
{{Specifications}}
Browser compatibility
{{Compat}}
See also
Improving user privacy and developer experience with User-Agent Client Hints (web.dev)
{{HTTPHeader("Accept-CH")}}
HTTP Caching > Varying responses and {{HTTPHeader("Vary")}}