Critical-CH
The HTTP Critical-CH response header lists client hint headers the server considers essential for rendering the correct response.
Usage
The Critical-CH header is part of the Client Hints infrastructure. Servers use Accept-CH to declare which client hint headers they accept. The Critical-CH header goes further by marking a subset of those hints as critical. If a browser sends a request without including the listed critical hints, the browser automatically retries the request with those headers attached before rendering the page.
This retry mechanism solves a timing problem. On a first visit, the browser has no way of knowing which client hints the server needs. The Accept-CH header in the response teaches the browser for future navigations, but the initial page load arrives without the needed hints. Critical-CH triggers an immediate retry so the server receives the correct hints on the first page load.
The retry happens at most once per request to prevent loops. If the browser already sent the critical hint or declines to send the hint (due to privacy settings or lack of support), no retry occurs. The browser compares what hints are now sendable given the updated Accept-CH preferences against what was originally sent. Only missing hints trigger the retry. Requests using unsafe methods like POST and PUT are never retried because of potential side effects.
Each header listed in Critical-CH must also appear in the Accept-CH and Vary response headers. The Vary header ensures caches store separate versions based on the hint values.
Note
The Critical-CH header is supported by Chromium-based browsers. The header requires a secure context (HTTPS).
Values
Client hint header list
The value is a comma-delimited list of client hint header
names. Common values include Sec-CH-UA-Mobile,
Sec-CH-UA-Platform-Version, Sec-CH-UA-Model,
Sec-CH-UA-Arch, Sec-CH-UA-Bitness,
Sec-CH-UA-Full-Version-List, and
Sec-CH-Prefers-Color-Scheme.
Example
A server marks several User-Agent client hints as critical for adaptive content delivery. The browser checks whether these headers were included in the original request. If any are missing, the browser retries the request with all listed hints attached.
Accept-CH: Sec-CH-UA-Bitness, Sec-CH-UA-Arch,
Sec-CH-UA-Full-Version-List, Sec-CH-UA-Mobile,
Sec-CH-UA-Model, Sec-CH-UA-Platform-Version
Critical-CH: Sec-CH-UA-Bitness, Sec-CH-UA-Arch,
Sec-CH-UA-Full-Version-List, Sec-CH-UA-Mobile,
Sec-CH-UA-Model, Sec-CH-UA-Platform-Version
Vary: Sec-CH-UA-Bitness, Sec-CH-UA-Arch,
Sec-CH-UA-Full-Version-List, Sec-CH-UA-Mobile,
Sec-CH-UA-Model, Sec-CH-UA-Platform-Version
A site serving different color schemes uses
Sec-CH-Prefers-Color-Scheme as a critical hint. The
server tailors the initial HTML and CSS to match the
preferred color scheme, avoiding a flash of incorrect
colors on first load.
Accept-CH: Sec-CH-Prefers-Color-Scheme
Critical-CH: Sec-CH-Prefers-Color-Scheme
Vary: Sec-CH-Prefers-Color-Scheme
Takeaway
The Critical-CH header ensures a server receives essential client hint data on the first page load by triggering a browser retry when critical hints are missing from the initial request.
See also
- Client Hints Infrastructure (WICG)
- Critical-CH (Chrome Status)
- Accept-CH
- Vary
- Client-Hints
- HTTP headers