Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Send Sec-Purpose: prefetch header for prefetch requests #1576

Merged
merged 8 commits into from
Jan 17, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions fetch.bs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ urlPrefix:https://httpwg.org/specs/rfc8941.html#;type:dfn;spec:rfc8941
url:rfc.section.2;text:structured field value
url:text-serialize;text:serializing structured fields
url:text-parse;text:parsing structured fields
url:;text:structured header
url:token;text:structured field token

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


<h3 id="sec-purpose-header">`<code>Sec-Purpose</code>` header</h3>

<p>The `<dfn export http-header id=http-sec-purpose><code>Sec-Purpose</code></dfn>` HTTP request
header specifies that the request serves one or more purposes other than requesting the resource for
immediate use by the user.

<p>The `<a http-header><code>Sec-Purpose</code></a>` header field is a <a>structured header</a>
whose value must be a <a data-lt="structured field token">token</a>.

<p>The sole <a data-lt="structured field token">token</a> defined is <code>prefetch</code>. It
indicates the request’s purpose is to fetch a resource that is anticipated to be needed shortly.

<p class=note>The server can use this to adjust the caching expiry for prefetches, to disallow the
prefetch, or to treat it differently when counting page visits.


annevk marked this conversation as resolved.
Show resolved Hide resolved

<h2 id=fetching>Fetching</h2>

Expand Down Expand Up @@ -5313,6 +5331,11 @@ run these steps:
<li><p><a abstract-op lt="append the Fetch metadata headers for a request">Append the Fetch metadata headers for <var>httpRequest</var></a>.
[[!FETCH-METADATA]]

<li><p>If <var>httpRequest</var>'s <a for=request>initiator</a> is "<code>prefetch</code>", then
<a>set a structured field value</a> given (`<a http-header><code>Sec-Purpose</code></a>`,
the <a data-lt="structured field token">token</a> <code>prefetch</code>) in
<var>httpRequest</var>'s <a for=request>header list</a>.

<li><p>If <var>httpRequest</var>'s <a for=request>header list</a>
<a for="header list">does not contain</a> `<code>User-Agent</code>`, then user agents should
<a for="header list">append</a> (`<code>User-Agent</code>`,
Expand Down