whatwg / fetch

Fetch Standard

Home Page:https://fetch.spec.whatwg.org/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

fetch does not allow caching requests with a null client

cbiesinger opened this issue · comments

What problem are you trying to solve?

The FedCM spec (https://fedidcg.github.io/FedCM/) makes a number of fetch requests with a null client, such as https://fedidcg.github.io/FedCM/#fetch-config-file. But fetch does not support caching requests with a null client because the cache partition is null (https://fetch.spec.whatwg.org/#network-partition-keys via https://fetch.spec.whatwg.org/#http-cache-partitions). Because these files change rarely, it is desirable to be able to cache them if requested by the server using standard HTTP headers

What solutions exist today?

Only solution today is to cache them in the caller of fetch, which is a lot of complexity to duplicate what the HTTP cache does today

How would you solve it?

Probably one of:

  • add a property to fetch requests named something like "cache fallback environment" that would be used by the cache partition key algorithm
  • allow the fetch caller to specify a network partition key directly (not exposed to JS, of course)

Anything else?

@domfarolino suggested not using the "reserved client" for this purpose because it's meant to be used for navigation requests

See also #1296 and #1673.