Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

preloadData should be able to cache multiple routes at a time #12122

Open
rileylyman opened this issue Apr 14, 2024 · 0 comments
Open

preloadData should be able to cache multiple routes at a time #12122

rileylyman opened this issue Apr 14, 2024 · 0 comments
Labels
feature request New feature or request

Comments

@rileylyman
Copy link

Describe the problem

Reading the docs and using preloadData, I had always assumed I could call it multiple times and that it would cache each route. I've actually been using it this way for months and never noticed somehow. Due to lack of documentation of this limitation, I was very confused for a while and it wasn't until I dug into the code that I confirmed my suspicions that the load cache can only store one route at a time.

Describe the proposed solution

I think preloadData should be able to cache multiple routes at a time. Perhaps the maximum number of routes to be cached could be set in the config or something. This would be a huge help for my app where many pages make lots of fetches that could be effectively hidden this way.

I understand that it isn't really desirable to cache a bunch of routes when you are hovering over links with data-sveltekit-preload-data="hover", but I think that when the dev calls preloadData manually, there is no reason to clear the other cached routes in that case. If the dev did want to clear the cache, maybe that could be an optional argument to preloadData or a separate function entirely, but I think that's overcomplicating it.

I think the simplest thing would be just to allow N number of routes to be cached at the same time, tweakable by the user via config.

Alternatives considered

No response

Importance

would make my life easier

Additional Information

No response

@eltigerchino eltigerchino added the feature request New feature or request label Apr 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants