Skip to content

Commit

Permalink
<link rel=preload> integration
Browse files Browse the repository at this point in the history
Before any particular fetch steps are performed, see if there is a matching request already in the preload store and consume it.

This is called from the main fetch to avoid race conditions.

Depends on whatwg/html#7260, and together they fix whatwg#590.

Tests: web-platform-tests/wpt#31539.
  • Loading branch information
noamr authored and ericorth committed Feb 18, 2022
1 parent 6cf4159 commit 8010e2c
Showing 1 changed file with 40 additions and 0 deletions.
40 changes: 40 additions & 0 deletions fetch.bs
Original file line number Diff line number Diff line change
Expand Up @@ -3841,6 +3841,46 @@ the request.
<var>request</var>'s <a for=request>origin</a> to <var>request</var>'s <a for=request>client</a>'s
<a for="environment settings object">origin</a>.

<li>
<p>If all of the following conditions are true:

<ul class=brief>
<li><p><var>request</var>'s <a for=request>URL</a>'s <a for=url>scheme</a> is an
<a>HTTP(S) scheme</a>

<li><p><var>request</var>'s <a for=request>mode</a> is "<code>same-origin</code>",
"<code>cors</code>", or "<code>no-cors</code>"

<li><p><var>request</var>'s <a for=request>window</a> is not null

<li><p><var>request</var>'s <a for=request>method</a> is `<code>GET</code>`

<li><p><var>request</var>'s <a for=request>unsafe-request flag</a> is not set or
<var>request</var>'s <a for=request>header list</a> <a for="list">is empty</a>
</ul>

<p>then:

<ol>
<li><p><a for=/>Assert</a>: <var>request</var>'s <a for=request>origin</a> is <a>same origin</a>
with <var>request</var>'s <a for=request>client</a>'s
<a for="environment settings object">origin</a>.

<li><p>Let <var>onPreloadedResponseAvailable</var> be an algorithm that runs the following
step <a>in parallel</a> given a <a for=/>response</a> <var>response</var>: run
<a>fetch finale</a> given <var>response</var> and <var>fetchParams</var>.

<li><p>Let <var>foundPreloadedResource</var> be the result of invoking
<a>consume a preloaded resource</a> for <var>req</var>'s <a for=request>window</a>,
given <var>req</var>'s <a for=request>URL</a>, <var>req</var>'s <a for=request>destination</a>,
<var>req</var>'s <a for=request>mode</a>, <var>req</var>'s <a for=request>credentials mode</a>,
<var>req</var>'s <a for=request>integrity metadata</a>, and
<var>onPreloadedResponseAvailable</var>.

<li><p>If <var>foundPreloadedResource</var> is true, then return.
</ol>
</li>

<li>
<p>If <var>request</var>'s <a for=request>policy container</a> is "<code>client</code>", then:

Expand Down

0 comments on commit 8010e2c

Please sign in to comment.