Skip to content

Commit c68b8e3

Browse files
noamrannevk
andauthored
Define Sec-Purpose: prefetch header
This replaces the existing `Purpose: prefetch` and `x-moz: prefetch` headers. Tests: web-platform-tests/wpt#35707. Part of whatwg/html#8111. Closes w3c/webappsec-fetch-metadata#84 and w3c/resource-hints#74. Co-authored-by: Anne van Kesteren <[email protected]>
1 parent a824dd3 commit c68b8e3

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

fetch.bs

+23
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ urlPrefix:https://httpwg.org/specs/rfc8941.html#;type:dfn;spec:rfc8941
1818
url:rfc.section.2;text:structured field value
1919
url:text-serialize;text:serializing structured fields
2020
url:text-parse;text:parsing structured fields
21+
url:;text:structured header
22+
url:token;text:structured field token
2123

2224
urlPrefix:https://httpwg.org/specs/rfc9110.html#;type:dfn;spec:http
2325
url:method.overview;text:method
@@ -4088,6 +4090,22 @@ run these steps:
40884090
</div>
40894091

40904092

4093+
<h3 id="sec-purpose-header">`<code>Sec-Purpose</code>` header</h3>
4094+
4095+
<p>The `<dfn export http-header id=http-sec-purpose><code>Sec-Purpose</code></dfn>` HTTP request
4096+
header specifies that the request serves one or more purposes other than requesting the resource for
4097+
immediate use by the user.
4098+
4099+
<p>The `<a http-header><code>Sec-Purpose</code></a>` header field is a <a>structured header</a>
4100+
whose value must be a <a data-lt="structured field token">token</a>.
4101+
4102+
<p>The sole <a data-lt="structured field token">token</a> defined is <code>prefetch</code>. It
4103+
indicates the request’s purpose is to fetch a resource that is anticipated to be needed shortly.
4104+
4105+
<p class=note>The server can use this to adjust the caching expiry for prefetches, to disallow the
4106+
prefetch, or to treat it differently when counting page visits.
4107+
4108+
40914109

40924110
<h2 id=fetching>Fetching</h2>
40934111

@@ -5327,6 +5345,11 @@ run these steps:
53275345
<li><p><a abstract-op lt="append the Fetch metadata headers for a request">Append the Fetch metadata headers for <var>httpRequest</var></a>.
53285346
[[!FETCH-METADATA]]
53295347

5348+
<li><p>If <var>httpRequest</var>'s <a for=request>initiator</a> is "<code>prefetch</code>", then
5349+
<a>set a structured field value</a> given (`<a http-header><code>Sec-Purpose</code></a>`,
5350+
the <a data-lt="structured field token">token</a> <code>prefetch</code>) in
5351+
<var>httpRequest</var>'s <a for=request>header list</a>.
5352+
53305353
<li><p>If <var>httpRequest</var>'s <a for=request>header list</a>
53315354
<a for="header list">does not contain</a> `<code>User-Agent</code>`, then user agents should
53325355
<a for="header list">append</a> (`<code>User-Agent</code>`,

0 commit comments

Comments
 (0)