Skip to content

Commit 703e127

Browse files
authored
Specify <link rel=prefetch>
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.
1 parent 1515288 commit 703e127

File tree

1 file changed

+48
-5
lines changed

1 file changed

+48
-5
lines changed

source

Lines changed: 48 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26048,15 +26048,58 @@ document.body.appendChild(wbr);</code></pre>
2604826048
link</span>. This keyword is <span>body-ok</span>.</p>
2604926049

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

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

26058+
<p>The <span>fetch and process the linked resource</span> algorithm for <code
26059+
data-x="rel-prefetch">prefetch</code> links, given a <code>link</code> element
26060+
<var>el</var>, is as follows:</p>
26061+
26062+
<ol>
26063+
<li><p>If <var>el</var>'s <code data-x="attr-link-href">href</code> attribute's value is the
26064+
empty string, then return.</p></li>
26065+
26066+
<li><p>Let <var>options</var> be the result of <span data-x="create link options from
26067+
element">creating link options</span> from <var>el</var>.</p></li>
26068+
26069+
<li><p>Set <var>options</var>'s <span data-x="link options destination">destination</span> to
26070+
the empty string.</p></li>
26071+
26072+
<li><p>Let <var>request</var> be the result of <span data-x="create a link request">creating a
26073+
link request</span> given <var>options</var>.</p></li>
26074+
26075+
<li><p>If <var>request</var> is null, then return.</p></li>
26076+
26077+
<li><p>Set <var>request</var>'s <span data-x="concept-request-initiator">initiator</span> to
26078+
"<code data-x="">prefetch</code>".</p></li>
26079+
26080+
<li>
26081+
<p>Let <var>processPrefetchResponse</var> be the following steps given a <span
26082+
data-x="concept-response">response</span> <var>response</var> and null, failure, or a
26083+
<span>byte sequence</span> <var>bytesOrNull</var>:</p>
26084+
26085+
<ol>
26086+
<li><p>If <var>response</var> is a <span>network error</span>, <span
26087+
data-x="concept-event-fire">fire an event</span> named <code
26088+
data-x="event-error">error</code> at <var>el</var>.</p></li>
26089+
26090+
<li><p>Otherwise, <span data-x="concept-event-fire">fire an event</span> named <code
26091+
data-x="event-load">load</code> at <var>el</var>.</p></li>
26092+
</ol>
26093+
</li>
26094+
26095+
<li><p>The user agent should <span data-x="concept-fetch">fetch</span> <var>request</var>, with
26096+
<i data-x="processResponseConsumeBody">processResponseConsumeBody</i> set to
26097+
<var>processPrefetchResponse</var>. User agents may delay the fetching of <var>request</var> to
26098+
prioritize other requests that are necessary for the current document.</p></li>
26099+
</ol>
26100+
26101+
<p>The <span>process a link header</span> steps for this type of linked resource are to do
26102+
nothing.</p>
2606026103

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

0 commit comments

Comments
 (0)