Skip to content

Commit

Permalink
Specify <link rel=prefetch>
Browse files Browse the repository at this point in the history
Prefetch is simply a fetch, which populates the HTTP cache, with no post-processing of the resource and with a special header Sec-Purpose: prefetch. (The latter is specified in whatwg/fetch#1576.)

Closes #5229.
Closes w3c/resource-hints#86.
Closes w3c/resource-hints#74.
Closes whatwg/fetch#1008.
  • Loading branch information
noamr authored Jan 17, 2023
1 parent 1515288 commit 703e127
Showing 1 changed file with 48 additions and 5 deletions.
53 changes: 48 additions & 5 deletions source
Original file line number Diff line number Diff line change
Expand Up @@ -26048,15 +26048,58 @@ document.body.appendChild(wbr);</code></pre>
link</span>. This keyword is <span>body-ok</span>.</p>

<p>The <code data-x="rel-prefetch">prefetch</code> keyword indicates that preemptively <span
data-x="concept-fetch">fetching</span> and caching the specified resource is likely to be
beneficial, as it is highly likely that the user will require this resource for future
navigations. <span w-nodev>User agents must implement the processing model of the <code
data-x="rel-prefetch">prefetch</code> keyword described in <cite>Resource Hints</cite>.</span>
<ref spec=RESOURCEHINTS></p>
data-x="concept-fetch">fetching</span> and caching the specified resource or same-site document is
likely to be beneficial, as it is highly likely that the user will require this resource for
future navigations.</p>

<p>There is no default type for resources given by the <code data-x="rel-prefetch">prefetch</code>
keyword.</p>

<p>The <span>fetch and process the linked resource</span> algorithm for <code
data-x="rel-prefetch">prefetch</code> links, given a <code>link</code> element
<var>el</var>, is as follows:</p>

<ol>
<li><p>If <var>el</var>'s <code data-x="attr-link-href">href</code> attribute's value is the
empty string, then return.</p></li>

<li><p>Let <var>options</var> be the result of <span data-x="create link options from
element">creating link options</span> from <var>el</var>.</p></li>

<li><p>Set <var>options</var>'s <span data-x="link options destination">destination</span> to
the empty string.</p></li>

<li><p>Let <var>request</var> be the result of <span data-x="create a link request">creating a
link request</span> given <var>options</var>.</p></li>

<li><p>If <var>request</var> is null, then return.</p></li>

<li><p>Set <var>request</var>'s <span data-x="concept-request-initiator">initiator</span> to
"<code data-x="">prefetch</code>".</p></li>

<li>
<p>Let <var>processPrefetchResponse</var> be the following steps given a <span
data-x="concept-response">response</span> <var>response</var> and null, failure, or a
<span>byte sequence</span> <var>bytesOrNull</var>:</p>

<ol>
<li><p>If <var>response</var> is a <span>network error</span>, <span
data-x="concept-event-fire">fire an event</span> named <code
data-x="event-error">error</code> at <var>el</var>.</p></li>

<li><p>Otherwise, <span data-x="concept-event-fire">fire an event</span> named <code
data-x="event-load">load</code> at <var>el</var>.</p></li>
</ol>
</li>

<li><p>The user agent should <span data-x="concept-fetch">fetch</span> <var>request</var>, with
<i data-x="processResponseConsumeBody">processResponseConsumeBody</i> set to
<var>processPrefetchResponse</var>. User agents may delay the fetching of <var>request</var> to
prioritize other requests that are necessary for the current document.</p></li>
</ol>

<p>The <span>process a link header</span> steps for this type of linked resource are to do
nothing.</p>

<h5>Link type "<dfn for="link/rel" attr-value><code
data-x="rel-preload">preload</code></dfn>"</h5>
Expand Down

0 comments on commit 703e127

Please sign in to comment.