[w3c/ServiceWorker] `Vary` and requests added below the SW (#1542)

I learned recently that [`Cache.match()`](https://developer.mozilla.org/en-US/docs/Web/API/Cache/match) is taking the Vary headers into account when matching requests and responses. That seems neat.

At the same time, for request headers added below the SW (e.g. `Cookie`, `User-Agent`) that doesn't seem like something that can work: The server indicates that the request would vary based on the user state or browser version, but that is not respected because the `Request` objects the SW's `fetch` event sees don't contain those headers and would always match, even if those headers changed in the underlying layers.

The reason I'm looking into this is that for Client Hints, we decided on adding them above the SW in order to have visibility into their values when matching responses, but that has many downsides, especially when it comes to SW generated requests.

Maybe the right path here is a way to provide those relevant values to `match()` (coming from the relevant JS APIs) in a generic way that'd enable it to take them into account?

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

Received on Thursday, 24 September 2020 10:10:52 UTC