Skip to content

Commit

Permalink
Attempt to reuse preloaded responses.
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
  • Loading branch information
noamr committed Oct 26, 2021
1 parent bcd4a44 commit d6f7478
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions fetch.bs
Original file line number Diff line number Diff line change
Expand Up @@ -3848,11 +3848,18 @@ steps:
<ol>
<li><p>Let <var>request</var> be <var>fetchParams</var>'s <a for="fetch params">request</a>.

<li><p>Let <var>response</var> be null.
<li>
<p>Let <var>response</var> be the result of invoking <span>consume a preloaded resource</span>
for <var>request</var>.

<p class="note">This is done in main fetch and not in HTTP-fetch to avoid blocking or race
conditions between the networking queue and the document queue. The implication is that if a
fetch redirects to a URL that was preloaded, it would not be consumed.</p>
</li>

<li><p>If <var>request</var>'s <a>local-URLs-only flag</a> is set and <var>request</var>'s
<a for=request>current URL</a> is not <a lt="is local">local</a>, then set <var>response</var> to a
<a>network error</a>.
<li><p>If <var>response</var> is null, <var>request</var>'s <a>local-URLs-only flag</a> is set and
<var>request</var>'s <a for=request>current URL</a> is not <a lt="is local">local</a>, then set
<var>response</var> to a <a>network error</a>.

<li><p>Run <a>report Content Security Policy violations for <var>request</var></a>.

Expand Down

0 comments on commit d6f7478

Please sign in to comment.