AcceptCHCache Class

The Accept-CH cache of the user agent (https://wicg.github.io/client-hints-infrastructure/#accept-ch-cache): the client hints that each origin opted into with the Accept-CH header of the response of a top-level navigation, which are sent with the next requests to the origin (see BrowsingContextOptions.AcceptCHCache).

public sealed class AcceptCHCache

Remarks

The cache is keyed by the serialization of the origins (e.g. https://example.com), and its values are client hints tokens: the names of the request headers in lowercase (e.g. sec-ch-ua-arch). The names that are not client hints tokens are ignored. An origin that opted out (an empty Accept-CH header) has an empty entry.

The cache acts as a cookie store (a site can use the hints as bits of an identifier): clear it when the cookies are cleared. It is kept in memory: to persist it, save its entries (AcceptCHCache.GetOrigins and AcceptCHCache.GetClientHints) and restore them with AcceptCHCache.SetClientHints. The cache is thread-safe: it can be shared by several browsing contexts.

Constructors

NameDescription
AcceptCHCache()

AcceptCHCache()

AcceptCHCache.cs
public AcceptCHCache()

No documentation is available.

Methods

NameDescription
Clear()Removes all the entries.
GetClientHints(string)Returns the client hints tokens of an origin (e.g. sec-ch-ua-arch): empty when the origin has no entry.
GetOrigins()Returns the serialized origins that have an entry in the cache.
Remove(string)Removes the entry of an origin, as the Clear-Site-Data header does. Returns whether the origin had an entry.
SetClientHints(string, IEnumerable<string>)Creates or overrides the entry of an origin.

Removes all the entries.

public void Clear()

GetClientHints(string)

AcceptCHCache.cs

Returns the client hints tokens of an origin (e.g. sec-ch-ua-arch): empty when the origin has no entry.

public IReadOnlyList<string> GetClientHints(string origin)

Parameters

origin string
The serialization of the origin (e.g. https://example.com).

Returns

IReadOnlyList<string>

GetOrigins()

AcceptCHCache.cs

Returns the serialized origins that have an entry in the cache.

public IReadOnlyList<string> GetOrigins()

Remove(string)

AcceptCHCache.cs

Removes the entry of an origin, as the Clear-Site-Data header does. Returns whether the origin had an entry.

public bool Remove(string origin)

Parameters

origin string
The serialization of the origin (e.g. https://example.com).

Returns

bool

SetClientHints(string, IEnumerable<string>)

AcceptCHCache.cs

Creates or overrides the entry of an origin.

public void SetClientHints(string origin, IEnumerable<string> clientHints)

Parameters

origin string
The serialization of the origin (e.g. https://example.com).
clientHints IEnumerable<string>
The client hints tokens (ASCII case-insensitive); the other names are ignored.