[whatwg/fetch] Skip unnecessary checks when we have a preloaded response candidate in main fetch (PR #1803)

This PR skips checks that are not needed when we have a preloaded response candidate in the [main fetch](https://fetch.spec.whatwg.org/#concept-main-fetch) algorithm. We talked about this offline at the last TPAC, but the main motivation behind this is to optimize reusing preloaded content where possible.

The main observable difference due to this change is that once a preload is made with a certain CSP policy, a subsequent request for the same resource will get the same response. This means that dynamically setting the CSP policy will not affect the ability to use preloaded content.

We could maybe argue the same for mixed content checks, but it seems better to respond to live changes in user preferences to block insecure content. Although, I'm open to thoughts and could see an argument either way.

This PR also skips all the irrelevant checks for clarity and ease of implementation, but another approach would be to only skip the observable checks in the spec.

@annevk @domenic Could you please take a look? Thank you!

<!--
Thank you for contributing to the Fetch Standard! Please describe the change you are making and complete the checklist below if your change is not editorial.

When you submit this PR, and each time you edit this comment (including checking a checkbox through the UI!), PR Preview will run and update it. As such make any edits in one go and only after PR Preview has run.

If you think your PR is ready to land, please double-check that the build is passing and the checklist is complete before pinging.
-->

- [ ] At least two implementers are interested (and none opposed):
   * …
   * …
- [ ] [Tests](https://github.com/web-platform-tests/wpt) are written and can be reviewed and commented upon at:
   * … <!-- If these tests are tentative, link a PR to make them non-tentative. -->
- [ ] [Implementation bugs](https://github.com/whatwg/meta/blob/main/MAINTAINERS.md#handling-pull-requests) are filed:
   * Chromium: …
   * Gecko: …
   * WebKit: …
   * Deno (not for CORS changes): …

(See [WHATWG Working Mode: Changes](https://whatwg.org/working-mode#changes) for more details.)


<!--
    This comment and the below content is programmatically generated.
    You may add a comma-separated list of anchors you'd like a
    direct link to below (e.g. #idl-serializers, #idl-sequence):

    Don't remove this comment or modify anything below this line.
    If you don't want a preview generated for this pull request,
    just replace the whole of this comment's content by "no preview"
    and remove what's below.
-->
***
<a href="https://whatpr.org/fetch/1803.html" title="Last updated on Jan 17, 2025, 9:15 AM UTC (94ef4ac)">Preview</a> | <a href="https://whatpr.org/fetch/1803/5dfed9d...94ef4ac.html" title="Last updated on Jan 17, 2025, 9:15 AM UTC (94ef4ac)">Diff</a>
You can view, comment on, or merge this pull request online at:

  https://github.com/whatwg/fetch/pull/1803

-- Commit Summary --

  * Skip unnecessary checks when we have a preloaded response candidate in main fetch

-- File Changes --

    M fetch.bs (24)

-- Patch Links --

https://github.com/whatwg/fetch/pull/1803.patch
https://github.com/whatwg/fetch/pull/1803.diff

-- 
Reply to this email directly or view it on GitHub:
https://github.com/whatwg/fetch/pull/1803
You are receiving this because you are subscribed to this thread.

Message ID: <whatwg/fetch/pull/1803@github.com>

Received on Friday, 17 January 2025 09:15:38 UTC