[w3c/ServiceWorker] Handle Fetch: Use correct storage key for subresource requests (PR #1790)

This change corrects the cache resolution logic within the Handle Fetch algorithm when the router source is RouterSourceEnum/"cache".

The Problem:
Previously, the algorithm always used reservedClient to resolve the storage key, regardless of the request type. However, reservedClient is only valid for top-level navigation requests and is not available for subresource requests. This could lead to accessing the incorrect cache storage during subresource fetches.

The Fix:
Logic has been added to differentiate between a non-subresource request and a subresource request.
- For a non-subresource request: It continues to use reservedClient as before.
- For a subresource request: It now uses the client associated with the request object.

This ensures that the correct storage key, based on the requesting client, is used for subresource requests.

Fixes: https://github.com/w3c/ServiceWorker/issues/1784


<!--
    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://pr-preview.s3.amazonaws.com/yoshisatoyanagisawa/ServiceWorker/pull/1790.html" title="Last updated on Sep 5, 2025, 2:09 AM UTC (d0832ba)">Preview</a> | <a href="https://pr-preview.s3.amazonaws.com/w3c/ServiceWorker/1790/953b6d3...yoshisatoyanagisawa:d0832ba.html" title="Last updated on Sep 5, 2025, 2:09 AM UTC (d0832ba)">Diff</a>
You can view, comment on, or merge this pull request online at:

  https://github.com/w3c/ServiceWorker/pull/1790

-- Commit Summary --

  * Handle Fetch: Use correct storage key for subresource requests

-- File Changes --

    M docs/index.bs (7)

-- Patch Links --

https://github.com/w3c/ServiceWorker/pull/1790.patch
https://github.com/w3c/ServiceWorker/pull/1790.diff

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

Message ID: <w3c/ServiceWorker/pull/1790@github.com>

Received on Friday, 5 September 2025 02:10:21 UTC