Re: [whatwg/fetch] Browsers preserve fragments on redirects (#505)

I don't think the cache.match request URL should be involved at all.  The state of the response is orthogonal to the key its stored under.

The principle I'm trying to preserve is that cache_storage does not mutate responses that flow through it.  So that this:

```javascript
evt.respondWith(fetch(request));
```

Should be equivalent to this:

```javascript
evt.respondWith(async function() {
  const r = await fetch(request);
  const c = await caches.open(name);
  c.put(request, r);
  return c.match(request);
}());
```

If we make cache_storage behave differently than a response returned from fetch() it creates a barrier to sites trying to use cache_storage for offline, reliability, etc.  Therefore I feel cache_storage should preserve the entire response exactly and reproduce it exactly (as possible).

To reiterate my overall desired outcome:

* If response.url exists and has a fragment, then respondWith() propagates that full url to the outer response.
* If response.url exists, but does not have a fragment, the respondWith() appends any FetchEvent.request.url fragment to the response.url.
* If response.url does not exist, then FetchEvent.request.url is uses.
* Response.url is preserved in cache_storage with fragments.

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/whatwg/fetch/issues/505#issuecomment-778293594

Received on Friday, 12 February 2021 16:22:38 UTC