Skip to content

Vary and requests added after the SW #1542

Closed
@yoavweiss

Description

@yoavweiss

I learned recently that 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 after 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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions