From 7a06a722b9b3156f7f9c4b2501f29c8f7512f3db Mon Sep 17 00:00:00 2001 From: Hamish Willee Date: Tue, 1 Jun 2021 18:32:57 +1000 Subject: [PATCH] Client hints updates (#4907) * Client hints, general updates * Assorted minor changes, mostly to frontmatter * Early-data is not a client hint header * Minor fixes * Update files/en-us/glossary/client_hints/index.html Co-authored-by: Florian Scholz * Update files/en-us/glossary/client_hints/index.html Co-authored-by: Florian Scholz Co-authored-by: Florian Scholz --- files/en-us/glossary/client_hints/index.html | 24 ++++++++----- .../glossary/forbidden_header_name/index.html | 11 +++--- .../headers/accept-ch-lifetime/index.html | 15 +++++--- .../web/http/headers/accept-ch/index.html | 34 +++++++++++++------ .../web/http/headers/device-memory/index.html | 3 ++ files/en-us/web/http/headers/dpr/index.html | 5 ++- .../web/http/headers/early-data/index.html | 7 ++-- .../http/headers/feature-policy/index.html | 1 - files/en-us/web/http/headers/index.html | 10 +++--- .../web/http/headers/save-data/index.html | 12 +++---- 10 files changed, 80 insertions(+), 42 deletions(-) diff --git a/files/en-us/glossary/client_hints/index.html b/files/en-us/glossary/client_hints/index.html index c537e2970e791fc..00c7a4078689242 100644 --- a/files/en-us/glossary/client_hints/index.html +++ b/files/en-us/glossary/client_hints/index.html @@ -8,23 +8,29 @@ - Reference - Web Performance --- -

Client Hints are a set of HTTP request header fields for proactive content negotiation allowing clients to indicate a list of device and agent specific preferences.

+

Client Hints are a set of HTTP request header fields that a server can proactively + request from a client in order to get its device and agent specific preferences. The set of "hint" headers are listed here: HTTP Headers > Client hints.

-

Use of client hints isn't automatic: rather, servers must announce that they support client hints. Servers announce support for Client Hints using the Accept-CH (accept client hints) header or an equivalent HTML meta element with the http-equiv attribute.

+

A server must announce that it supports client hints, using the {{HTTPHeader("Accept-CH")}} header to specify the hints that it is interested in recieving. + When a client that supports client hints receives the Accept-CH header it appends client hint headers that match the advertised field-values to subsequent requests.

-

Accept-CH: Width, Viewport-Width, Downlink

+

For example, following Accept-CH in a response below, the client could append {{HTTPHeader("Width")}}, {{HTTPHeader("Viewport-Width")}}, and {{HTTPHeader("Downlink")}} headers to all subsequent requests.

-

and / or

+
Accept-CH: Width, Viewport-Width, Downlink
-

<meta http-equiv="Accept-CH" content="Width, Viewport-Width, Downlink">

+

The server can then determine which resources to send based on the client information.

+ +
+

Note

+

Client hints can also be specified in HTML using the {{HTMLElement("meta")}} element with the http-equiv attribute.

+
<meta http-equiv="Accept-CH" content="Width, Viewport-Width, Downlink">
+
-

When a client receives the Accept-CH header, if supported, it appends Client Hint headers that match the advertised field-values. For example, based on Accept-CH example above, the client could append Width, Viewport-Width, and Downlink headers to all subsequent requests. In the second example, the server gives the browser the hints by setting the Accept-CH meta tag.

-

Basically, with the Client Hints header, the developer or application can tell the browser to advertise information about itself to the server, such as the device pixel ratio, the viewport width, and the display width. The client can then give the server information about the client's environment, and the server can determine which resources to send based on that information.

Varying Client Hints

-

To convey to caches that different Client Hints may affect the response, the Vary HTTP header must be used.

+

To convey to caches that different Client Hints may affect the response, the {{HTTPHeader("Vary")}} HTTP header must be used.

Example varying response:

@@ -35,4 +41,6 @@

See also

diff --git a/files/en-us/glossary/forbidden_header_name/index.html b/files/en-us/glossary/forbidden_header_name/index.html index cd722c1ded43189..366e8654da68a7a 100644 --- a/files/en-us/glossary/forbidden_header_name/index.html +++ b/files/en-us/glossary/forbidden_header_name/index.html @@ -8,13 +8,13 @@ - Headers - forbidden --- -

A forbidden header name is the name of any HTTP header that cannot be modified programmatically; specifically, an HTTP request header name (in contrast with a {{Glossary("Forbidden response header name")}}).

+

A forbidden header name is the name of any HTTP header that cannot be modified programmatically; specifically, an HTTP request header name (in contrast with a {{Glossary("Forbidden response header name")}}).

Modifying such headers is forbidden because the user agent retains full control over them. Names starting with `Sec-` are reserved for creating new headers safe from {{glossary("API","APIs")}} using Fetch that grant developers control over headers, such as {{domxref("XMLHttpRequest")}}.

Forbidden header names start with Proxy- or Sec-, or are one of the following names:

-
    +
    • Accept-Charset
    • Accept-Encoding
    • Access-Control-Request-Headers
    • @@ -26,7 +26,7 @@
    • Date
    • DNT
    • Expect
    • -
    • Feature-Policy
    • +
    • Feature-Policy
    • Host
    • Keep-Alive
    • Origin
    • @@ -40,8 +40,9 @@
    • Via
    -
    -

    Note: The User-Agent header is no longer forbidden, as per spec — see forbidden header name list (this was implemented in Firefox 43) — it can now be set in a Fetch Headers object, or via XHR setRequestHeader().  However, Chrome will silently drop the header from Fetch requests (see Chromium bug 571722).

    +
    +

    Note

    +

    The User-Agent header is no longer forbidden, as per spec — see forbidden header name list (this was implemented in Firefox 43) — it can now be set in a Fetch Headers object, or via XHR setRequestHeader().  However, Chrome will silently drop the header from Fetch requests (see Chromium bug 571722).

    +

    Specifications

    + + + + + + + + + + + + + + +
    SpecificationTitle
    {{RFC("8942", "Accept-CH")}}HTTP Client Hints
    +

    Browser compatibility

    {{Compat}}

    @@ -58,6 +73,5 @@

    Browser compatibility

    See also

      -
    • {{HTTPHeader("Accept-CH-Lifetime")}}
    • {{HTTPHeader("Vary")}}
    diff --git a/files/en-us/web/http/headers/device-memory/index.html b/files/en-us/web/http/headers/device-memory/index.html index 4e663d25c003a0a..d3bcc926c25d19b 100644 --- a/files/en-us/web/http/headers/device-memory/index.html +++ b/files/en-us/web/http/headers/device-memory/index.html @@ -2,10 +2,13 @@ title: Device-Memory slug: Web/HTTP/Headers/Device-Memory tags: + - Device-Memory - Client hints - Device Memory API - HTTP - HTTP Header + - Request header + - Experimental browser-compat: http.headers.Device-Memory ---
    {{HTTPSidebar}}{{securecontext_header}}{{SeeCompatTable}}
    diff --git a/files/en-us/web/http/headers/dpr/index.html b/files/en-us/web/http/headers/dpr/index.html index 03beee9d878f51b..e5e5d6fcf17bc34 100644 --- a/files/en-us/web/http/headers/dpr/index.html +++ b/files/en-us/web/http/headers/dpr/index.html @@ -2,18 +2,21 @@ title: DPR slug: Web/HTTP/Headers/DPR tags: + - DPR - Client hints - HTTP - HTTP Header + - Request header - Deprecated - Non-standard + - Exerimental browser-compat: http.headers.DPR ---
    {{deprecated_header}}{{Non-standard_header}}
    {{HTTPSidebar}}{{securecontext_header}}{{SeeCompatTable}}
    -

    The DPR header is a Client Hints header which represents the client device pixel ratio ({{Glossary("DPR")}}), which is the number of physical device pixels corresponding to every CSS pixel.

    +

    The DPR header is a Client Hints header which represents the client device pixel ratio, which is the number of physical device pixels corresponding to every CSS pixel.

    diff --git a/files/en-us/web/http/headers/early-data/index.html b/files/en-us/web/http/headers/early-data/index.html index 2bfe5805e729bff..22b16751329d8ae 100644 --- a/files/en-us/web/http/headers/early-data/index.html +++ b/files/en-us/web/http/headers/early-data/index.html @@ -2,10 +2,13 @@ title: Early-Data slug: Web/HTTP/Headers/Early-Data tags: + - Early-Data - Client hints - HTTP - - header - - request + - HTTP Header + - Request header + - Reference + - Experimental browser-compat: http.headers.Early-Data ---
    {{SeeCompatTable}}{{HTTPSidebar}}
    diff --git a/files/en-us/web/http/headers/feature-policy/index.html b/files/en-us/web/http/headers/feature-policy/index.html index 3b467dc982cb4b1..66de55142934642 100644 --- a/files/en-us/web/http/headers/feature-policy/index.html +++ b/files/en-us/web/http/headers/feature-policy/index.html @@ -4,7 +4,6 @@ tags: - Authorization - Experimental - - Feature Policy - Feature-Policy - HTTP - Permissions diff --git a/files/en-us/web/http/headers/index.html b/files/en-us/web/http/headers/index.html index 041358301fa37ca..0477345a1449d35 100644 --- a/files/en-us/web/http/headers/index.html +++ b/files/en-us/web/http/headers/index.html @@ -81,12 +81,12 @@

    Client hints

    {{HTTPHeader("Accept-CH")}} {{experimental_inline}}
    Servers can advertise support for Client Hints using the Accept-CH header field or an equivalent HTML <meta> element with http-equiv attribute ([HTML]).
    -
    {{HTTPHeader("Accept-CH-Lifetime")}} {{experimental_inline}}
    +
    {{HTTPHeader("Accept-CH-Lifetime")}} {{experimental_inline}} {{deprecated_inline}}
    Servers can ask the client to remember the set of Client Hints that the server supports for a specified period of time, to enable delivery of Client Hints on subsequent requests to the server’s origin ([RFC6454]).
    -
    {{HTTPHeader("Early-Data")}} {{experimental_inline}}
    -
    Indicates that the request has been conveyed in early data.
    {{HTTPHeader("Device-Memory")}} {{experimental_inline}}
    Technically a part of Device Memory API, this header represents an approximate amount of RAM client has.
    +
    {{HTTPHeader("DPR")}} {{deprecated_inline}}
    +
    Client device pixel ratio (DPR), which is the number of physical device pixels corresponding to every CSS pixel.
    {{HTTPHeader("Save-Data")}} {{experimental_inline}}
    A boolean that indicates the user agent's preference for reduced data usage.
    {{HTTPHeader("Viewport-Width")}} {{experimental_inline}}
    @@ -321,7 +321,7 @@

    Security

    HTTP Public Key Pinning (HPKP)

    -

    {{Glossary("HPKP", "HTTP Public Key Pinning (HPKP)")}} has been deprecated and removed in favor of Certificate Transparency and {{HTTPHeader("Expect-CT")}}.

    +

    {{Glossary("HPKP", "HTTP Public Key Pinning")}} has been deprecated and removed in favor of Certificate Transparency and {{HTTPHeader("Expect-CT")}}.

    {{HTTPHeader("Public-Key-Pins")}}
    @@ -395,6 +395,8 @@

    Other

    Used to list alternate ways to reach this service.
    {{HTTPHeader("Date")}}
    Contains the date and time at which the message was originated.
    +
    {{HTTPHeader("Early-Data")}} {{experimental_inline}}
    +
    Indicates that the request has been conveyed in TLS early data.
    {{HTTPHeader("Large-Allocation")}}
    Tells the browser that the page being loaded is going to want to perform a large allocation.
    {{HTTPHeader("Link")}}
    diff --git a/files/en-us/web/http/headers/save-data/index.html b/files/en-us/web/http/headers/save-data/index.html index 2a0b087c6676631..7e60cf9209028ba 100644 --- a/files/en-us/web/http/headers/save-data/index.html +++ b/files/en-us/web/http/headers/save-data/index.html @@ -2,12 +2,12 @@ title: Save-Data slug: Web/HTTP/Headers/Save-Data tags: -- HTTP -- HTTP Header -- Reference -- Request header -- Save-Data -- header + - Save-Data + - Client hints + - HTTP + - HTTP Header + - Reference + - Request header browser-compat: http.headers.Save-Data ---

    {{HTTPSidebar}}