-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Description
Describe the problem
SvelteKit include the ability to prefetch pages while the user is hovering over a link.
However, a the prefetched data might not be relevant after a period of time, so when the user will click on the link, say after a minute, she will get old data.
Describe the proposed solution
I think the simple solution is to allow to specify timeout.
Either allow to specify timeout in a syntax similar to <a sveltekit:prefetch={timeout: (time in seconds)} ...>
, or get the timeout from an optional "timeout" property in the return value of load() function, or even support both solutions.
A better/additional aprouch to the simple "timeout" property in my opinion, is to allow the developer to give a predicate:
function dataValidity(lastPrefetchedTime): boolean
Alternatives considered
The manual alternative would be to use some custom svelte action in the <a>
tag which calls prefetch() manually and call it again if the user hover/click on the link after a certain amount of time.
Sadly, as far as I know, there is not even a way to invalidate the prefetched data manually. (the invalidate() works only for the currently active page acoording to the docs)
Importance
would make my life easier
Additional Information
No response