Skip to content

Commit 992d70d

Browse files
authored
Add Sec-Purpose header for subresources when prerendering (#382)
Closes #371.
1 parent 55f9fca commit 992d70d

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

prefetch.bs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,7 @@ spec: prerendering-revamped; urlPrefix: prerendering.html
132132
type: dfn
133133
text: getting the supported loading modes; url: get-the-supported-loading-modes
134134
text: uncredentialed-prefetch; for: Supports-Loading-Mode; url: supports-loading-mode-uncredentialed-prefetch
135+
text: prerendering navigable; url: prerendering-navigable
135136
text: prerendering traversable; url: prerendering-traversable
136137
spec: no-vary-search; urlPrefix: https://httpwg.org/http-extensions/draft-ietf-httpbis-no-vary-search.html
137138
type: dfn
@@ -888,7 +889,7 @@ The following parameters are defined for the `prefetch` token:
888889

889890
* A parameter whose key is "<dfn for="Sec-Purpose prefetch">`prerender`</dfn>".
890891

891-
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.
892+
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. Note that this value is also set for resources made from within a [=prerendering navigable=], before activation.
892893

893894
<div class="note">
894895
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.

prerendering.bs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,8 @@ spec: nav-speculation; urlPrefix: prefetch.html
9797
text: prerendering traversable
9898
for: has a matching prefetch record
9999
text: checkPrerender
100+
for: Sec-Purpose prefetch
101+
text: prerender
100102
spec: RFC8941; urlPrefix: https://www.rfc-editor.org/rfc/rfc8941.html
101103
type: dfn
102104
text: structured header; url: #section-1
@@ -679,6 +681,20 @@ Modify <a abstract-op spec="CLEAR-SITE-DATA">clear site data for response</a>'s
679681
1. [=prefetch record/Cancel and discard=] |prefetchRecord| given |activeDocument|.
680682
</div>
681683

684+
<h3 id="interaction-with-fetch">Interaction with Fetch</h3>
685+
686+
<div algorithm="HTTP-network-or-cache fetch patch">
687+
Modify <a spec=FETCH>HTTP-network-or-cache fetch</a> by adding the following step after the existing step that sets [:Sec-Purpose:]:
688+
689+
1. Otherwise, if |httpRequest|'s [=request/client=] is an [=environment settings object=] whose [=environment settings object/global object=] is a {{Window}}, and that {{Window}}'s [=Window/navigable=] is a [=prerendering navigable=]:
690+
1. Let |purpose| be a [=structured header/List=] containing the [=structured header/Token=] `prefetch`.
691+
1. Add a parameter whose key is "<a for="Sec-Purpose prefetch">`prerender`</a>" and whose value is true to the `prefetch` token in |purpose|.
692+
1. [=header list/Set a structured field value=] given ([:Sec-Purpose:], |purpose|) in |httpRequest|'s [=request/header list=].
693+
694+
<p class="note">This includes both subresources within the prerendering navigable, and cases where the prerendering navigable is navigating itself.
695+
696+
</div>
697+
682698
<h2 id="supports-loading-mode">The \`<dfn export http-header><code>Supports-Loading-Mode</code></dfn>\` HTTP response header</h2>
683699

684700
<em>The following section would be added as a sub-section of [[HTML]]'s <a href="https://html.spec.whatwg.org/multipage/browsers.html#browsers">Loading web pages</a> section.</em>

0 commit comments

Comments
 (0)