You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Make all prerenders go via prefetching first (#359)
This allows deduplicating a good amount of the No-Vary-Search handling that both needed to do, and eliminates the entire "prerender records" concept.
Fixes#320 by properly specifying Sec-Purpose for prerenders.
Copy file name to clipboardExpand all lines: prefetch.bs
+20-13Lines changed: 20 additions & 13 deletions
Original file line number
Diff line number
Diff line change
@@ -182,6 +182,7 @@ A <dfn export>prefetch record</dfn> is a [=struct=] with the following [=struct/
182
182
* <dfn export for="prefetch record">label</dfn>, a [=string=]
183
183
184
184
<div class="note">This is intended for use by a specification or [=implementation-defined=] feature to identify which prefetches it created. It might also associate other data with this struct.</div>
185
+
* <dfn export for="prefetch record">prerendering traversable</dfn>, a [=prerendering traversable=], "`to be created`", or null (null by default)
185
186
* <dfn export for="prefetch record">state</dfn>, which is "`ongoing`" (the default), "`completed`", or "`canceled`"
186
187
<div class="note">"`canceled`" indicates that the prefetch was aborted by the author or user, or terminated by the user agent.</div>
187
188
* <dfn export for="prefetch record">fetch controller</dfn>, a [=fetch controller=] (a new [=fetch controller=] by default)
@@ -533,10 +534,11 @@ Modify the [=snapshot source snapshot params=] algorithm to set the return value
533
534
1. If |prefetchRecord| was given, then:
534
535
1. Let |purpose| be a [=structured header/List=] containing the [=structured header/Token=] `prefetch`.
535
536
1. If |prefetchRecord|'s [=prefetch record/anonymization policy=][=prefetch IP anonymization policy/requires anonymity=] for |request|, then:
536
-
1. Add a parameter whose key is <a for="Sec-Purpose prefetch" lt="anonymous-client-ip">"`anonymous-client-ip`"</a> and whose value is true to the `prefetch` token in |purpose|.
537
+
1. Add a parameter whose key is "<a for="Sec-Purpose prefetch">`anonymous-client-ip`</a>" and whose value is true to the `prefetch` token in |purpose|.
537
538
1. The user agent must use a [=connection=] which anonymizes the client IP address (e.g., using a proxy) when fetching |request|, or set |response| to a [=network error=] and [=iteration/break=].
538
539
539
540
<p class="issue">At the moment, how IP anonymization is achieved is handwaved. This will probably be done in an [=implementation-defined=] manner using some kind of proxy or relay. Ideally this would be plumbed down to [=obtain a connection=], and possibly even the mechanism could be further standardized.</p>
541
+
1. If |prefetchRecord|'s [=prefetch record/prerendering traversable=] is not null, then add a parameter whose key is "<a for="Sec-Purpose prefetch">`prerender`</a>" and whose value is true to the `prefetch` token in |purpose|.
540
542
1. [=header list/Set a structured field value=] given (<a http-header>`` `Sec-Purpose` ``</a>, |purpose|) in |request|'s [=request/header list=].
541
543
542
544
<div class="note">
@@ -662,13 +664,13 @@ This section contains patches to [[NAVIGATION-TIMING]].
662
664
The <dfn>list of sufficiently strict speculative navigation referrer policies</dfn> is a list containing the following: "", "`strict-origin-when-cross-origin`", "`strict-origin`", "`same-origin`", "`no-referrer`".
663
665
664
666
<div algorithm>
665
-
To <dfn export>prefetch</dfn> given a {{Document}} document and a [=prefetch record=] |prefetchRecord|, perform the following steps.
667
+
To <dfn export>prefetch</dfn> given a {{Document}}|document| and a [=prefetch record=] |prefetchRecord|, perform the following steps.
666
668
667
669
1. Let |sourceSnapshotParams| be the result of [=snapshotting source snapshot params=] given |document|.
668
670
1. Let |targetSnapshotParams| be the result of [=snapshotting target snapshot params=] given |document|'s [=node navigable=].
669
671
1. Set |prefetchRecord|'s [=prefetch record/source partition key=] to the result of [=determining the network partition key=] given |document|'s [=relevant settings object=].
670
672
1. [=Assert=]: |prefetchRecord|'s [=prefetch record/URL=]'s [=url/scheme=] is an [=HTTP(S) scheme=].
671
-
1. [=list/Append=] |prefetchRecord| to |document|'s [=Document/prefetch records=]
673
+
1. [=list/Append=] |prefetchRecord| to |document|'s [=Document/prefetch records=].
672
674
1. Set |prefetchRecord|'s [=prefetch record/start time=] to the [=current high resolution time=] for the [=relevant global object=] of |document|.
673
675
1. Set |prefetchRecord|'s [=prefetch record/sandboxing flag set=] to the result of [=determining the creation sandboxing flags=] for |document|'s [=Document/browsing context=] given |document|'s [=node navigable=]'s [=navigable/container=].
674
676
1. Let |referrerPolicy| be |prefetchRecord|'s [=prefetch record/referrer policy=] if |prefetchRecord|'s [=prefetch record/referrer policy=] is not the empty string, and |document|'s [=Document/policy container=]'s [=policy container/referrer policy=] otherwise.
@@ -768,19 +770,13 @@ The <dfn>list of sufficiently strict speculative navigation referrer policies</d
768
770
769
771
The <dfn http-header>`` `Sec-Purpose` ``</dfn> HTTP request header specifies that the request serves one or more purposes other than requesting the resource for immediate use by the user.
770
772
771
-
The header field is an [[RFC9651]] Structured Header whose value must be a [=structured header/List=]. Its ABNF is:
773
+
The header field is an [[RFC9651]] Structured Header whose value must be a [=structured header/List=].
772
774
773
-
```
774
-
Sec-Purpose = sf-list
775
-
```
775
+
It may contain an [=structured header/Item=] member which is the [=structured header/Token=] `prefetch`. If so, this indicates the request's purpose is to download a resource it is anticipated will be fetched shortly.
776
776
777
-
It may contain an [=structured header/Item=] member which is the [=structured header/Token=] "`prefetch`". If so, this indicates the request's purpose is to download a resource it is anticipated will be fetched shortly.
777
+
The following parameters are defined for the `prefetch` token:
778
778
779
-
<div class="issue">TODO: Are there normative implications of this that should be specified here?</div>
780
-
781
-
The following parameters are defined for the "`prefetch`" token:
782
-
783
-
* A parameter whose key is <dfn for="Sec-Purpose prefetch" lt="anonymous-client-ip">"`anonymous-client-ip`"</dfn>.
779
+
* A parameter whose key is "<dfn for="Sec-Purpose prefetch">`anonymous-client-ip`</dfn>".
784
780
785
781
If present with a value other than boolean false (`` `?0` `` in the field value), this parameter indicates that the prefetch request is being made using an anonymous client IP. Consequently, servers should not rely on it matching, or sharing a geographic location or network operator with, the client's IP address from which a non-prefetch request would have been made.
786
782
@@ -792,6 +788,17 @@ The following parameters are defined for the "`prefetch`" token:
792
788
This specification conforms to this advice; the [=prefetch=] algorithm does not emit non-boolean values.
793
789
</div>
794
790
791
+
* A parameter whose key is "<dfn for="Sec-Purpose prefetch">`prerender`</dfn>".
792
+
793
+
If present with a value other than boolean false (`` `?0` `` in the field value), this parameter indicates that the prefetch request is being made in anticipation of a prerender.
794
+
795
+
<div class="note">
796
+
A future specification might define assign more specific meaning to non-boolean values. For now, they are treated the same as true. Implementations are advised not to emit such values.
797
+
798
+
This specification conforms to this advice; the [=prefetch=] algorithm does not emit non-boolean values.
0 commit comments