Skip to content

Commit

Permalink
Update Critical-CH restart time in navigation params (#153)
Browse files Browse the repository at this point in the history
* Update Critical-CH restart time in navigation params

This is needed for w3c/navigation-timing#188.

* Update index.bs

* Update index.bs

* Update index.bs

* Update index.bs

* Update index.bs

* Update index.bs

* Update index.bs

* Update index.bs

* Update index.bs

* Update index.bs

* Update index.bs
  • Loading branch information
arichiv committed Jun 7, 2023
1 parent 96a82df commit 193d599
Showing 1 changed file with 31 additions and 13 deletions.
44 changes: 31 additions & 13 deletions index.bs
Expand Up @@ -115,7 +115,7 @@ following specifications and proposals:
same-origin or delegated-to cross-origin requests. It also makes sure
hints are removed from not delegated-to cross-origin requests after
redirections.
- Defines the `Critical-CH` response header, which servers may use to request a reload
- Defines the `Critical-CH` response header, which servers may use to request a restart
to include critical Client Hints missing in the initial load.
- Integrates those concepts with the [[!HTML]] and [[!FETCH]] specifications,
by patching various concepts there.
Expand Down Expand Up @@ -185,19 +185,21 @@ If an [=url/origin=] is loaded and the server sets an `Accept-CH` header that
lists hints not already in the current [=Accept-CH cache=] that means only
subsiquent loads of that [=url/origin=] will include the hints. If it's
critical that every load (including the first) has the requested Client Hints,
then the server can set a `Critical-CH` header to request a reload. The
then the server can set a `Critical-CH` header to request a restart. The
`Critical-CH` header itself does not modify the [=Accept-CH cache=].

A reload will only occur when a hint in the `Accept-CH` header is both *not in*
A restart will only occur when a hint in the `Accept-CH` header is both *not in*
the [=Accept-CH cache=] and *in* the `Critical-CH` header. If hints listed in
the `Critical-CH` header are already in the [=Accept-CH cache=] no reload is
the `Critical-CH` header are already in the [=Accept-CH cache=] no restart is
needed as they were sent. If hints listed in the `Critical-CH` header are not
in the `Accept-CH` header a reload would not result in the hints being included
in the `Accept-CH` header a restart would not result in the hints being included
anyway.

The restart retries the entire navigation (including any prior redirects).

There MAY be multiple `Critical-CH` headers per-response and <a>sf-lists</a> can be split across lines as long as each line contains at least one token.

When asked if the user agent <dfn abstract-op>should reload page for critical client hints</dfn> given a |settingsObject| and |response|:
When asked if the user agent <dfn abstract-op>should restart loading the page for critical client hints</dfn> given a |settingsObject| and |response|:

<ol>
<li>If |settingsObject| is a [=non-secure context=], abort these steps.
Expand Down Expand Up @@ -277,27 +279,43 @@ Navigable {#navigable}

Add a new field to [=navigable=]:
<ul>
<li>A <dfn>has reloaded for `Critical-CH`</dfn> boolean, initially `false`.
<li>A <dfn>`Critical-CH` restart time</dfn> {{DOMHighResTimeStamp}}, initially 0.
This records the time the navigation was restarted to ensure required Client Hint
headers will be sent.
</ul>

Navigation response {#navigation-response}
----------

At [=populating a session history entry=], in step 6 after substep 7 insert the following:
<ol>
<li>Let |shouldReloadForCriticalClientHints| be `false`.
<li>If <var>navigable</var>'s [=has reloaded for Critical-CH=] is `false`:
<li>Let |shouldRestartForCriticalClientHints| be `false`.
<li>If <var>navigable</var>'s [=Critical-CH restart time=] is 0:
<ol>
<li>Let |shouldReloadForCriticalClientHints| be the result of running [$should reload page for critical client hints$] with the [=relevant settings object=] and |response|.
<li>Let |shouldRestartForCriticalClientHints| be the result of running [$should restart page for critical client hints$] with the [=relevant settings object=] and |response|.
</ol>
<li>Run [$create or override the cached client hints set$] with the [=relevant settings object=] and |response| as inputs.
<li>If |shouldReloadForCriticalClientHints| then:
<li>If |shouldRestartForCriticalClientHints| then:
<ol>
<li>Set <var>navigable</var>'s [=Critical-CH restart time=] to the [=current high resolution time=].
<li>Restart the initial navigation (before any redirects).
</ol>
<li>If <var>navigable</var>'s [=Critical-CH restart time=] is not 0:
<ol>
<li>Set <var>navigable</var>'s [=has reloaded for Critical-CH=] to `true`.
<li><a spec=HTML>reload</a> <var>navigable</var>.
<li>Set <var>navigationParams</var>'s [=Critical-CH restart time=] to be <var>navigable</var>'s [=Critical-CH restart time=].
</ol>
</ol>

Issue(154): Clarify how "Restart the initial navigation (before any redirects)" integrates with the HTML spec.

At [=navigation params=], append the following:
<dl>
<dt>`Critical-CH` restart time</dt>
<dd>a {{DOMHighResTimeStamp}} used for [=creating the navigation timing entry=] for the new <code>Document</code>.
This records the time the navigation was restarted to ensure required Client Hint headers will be sent.</dd>
</dl>


Service Worker initialization {#service-worker-init}
-----------
At <a spec=HTML>set up a worker environment settings object</a>,
Expand Down

0 comments on commit 193d599

Please sign in to comment.