Re: [whatwg/fetch] Define the "Preload Cache" (#590)

> I agree that the "preload cache" doesn't need an eviction policy, size limits, etc.
> 
> I'm not sure I see the benefits of defining that cache above Fetch. It seems like it would significantly increase the room for mistakes on the part of the different Fetch callers.

I meant above fetch conceptually, like above what fetch currently does.

Though I think we anyway need to add a layerthat's equivalent to the browser engines' "resource loader" concepts, which sits between the individual resources and the current fetch, and does things like report resource timing. I think that preload handling should be done at that layer, as unlike fetch it has a concept of the document and it would be easier to create 1:1 mappings with a link element there rather than create elaborate new API and storage in FETCH.

> 
> I'm similarly not sure we need to evict preloads from the cache if their corresponding `<link>` is removed. I don't think this is what current implementations do. What's the use case this will enable?
> 
Allowing the applications to free memory if it preloaded a lot of resources that are no longer needed. But it's sort of a "side" case.

Also, forcing the browser to make another request. If you want to preload a resource that has `no-cache` headers but you still want to preload it, you can preload it with `<link rel="preload" />` and then decide for yourself when to "invalidate" that preloaded version.
It's straightforward enough for creating predictable WPT tests for it, I believe.

> Also, I think it's worthwhile to also think of generalizing the "list of available images" from HTML as a generic cache for all resource types, which is how it's implemented in at least 2 engines. While I wouldn't want to couple both efforts, it'd be good to have a holistic high-level design to how they'd both work.

I like the idea, but I think it's totally separated from the preload list. Preload (IMO) should be roughly equivalent to asking the document whether it currently has a `<link rel="preload"> in the DOM and querying that element for its response, and this is separate from any cache mechanism.

-- 
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/590#issuecomment-925620579

Received on Thursday, 23 September 2021 08:51:37 UTC