Skip to content
This repository has been archived by the owner on Jan 11, 2023. It is now read-only.

Better prefetch cache? #483

Open
mrkishi opened this issue Oct 18, 2018 · 0 comments
Open

Better prefetch cache? #483

mrkishi opened this issue Oct 18, 2018 · 0 comments

Comments

@mrkishi
Copy link
Member

mrkishi commented Oct 18, 2018

Currently, sapper will only cache one prefetched page at a time. That works fine and means we don't have to deal with memory growth, but consider the following scenario:

  • User hovers link to /a, /a's preloaded data gets saved
  • User hovers link to /b, /as preloaded data gets discarded and /b's replaces it
  • User navigates to /a, /a preloads again
  • User navigates to /b, /b preloads again

It's wasteful to prefetch a link just to throw it away and prefetch it again. I think we should consider a caching mechanism that allowed for multiple pages to be saved and for the invalidation to be configured per project.

A simple expiration in seconds with cleanup on navigation would already be better than what we currently have, imo. Thoughts?

ps. the current prefetching code will also use the latest preloaded page to figure out if it should preload a new one or not, making goto(currentPage) a noop if you haven't preloaded anything, but not a noop if you have.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant