Intelligently cache and bundle routeLoader$ requests #246
DustinJSilk
started this conversation in
Proposals For Qwik
Replies: 2 comments 1 reply
-
we also need to consider the security implications of letting the browser cache data that might be per-user. Since q-data is only fetched for SPA, perhaps we should implement the caching layer ourselves with localstorage instead, and always serve it with no-cache. |
Beta Was this translation helpful? Give feedback.
1 reply
-
This is being implemented in QwikDev/qwik#7979 |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
What is it about?
Bundle routeLoader$ requests based on Cache-Control settings
What's the motivation for this proposal?
Problems you are trying to solve:
Goals you are trying to achieve:
Any other context or information you want to share:
An initial discussion of this idea started here: #171 (comment)
Proposed Solution / Feature
What do you propose?
session
will allow routeLoaders to be cached for the current session only or until the cache expires. Session cached loaders do not return an actual Cache-Control header as the routeLoaders are bundled together. The cache control settings would be returned in the JSON response and cached in memory.must-revalidate
is set on the cacheControl, Qwik will automatically refetch the routeLoader$ when it expires. This ensures data remains fresh and allows to add polling behaviour with minimal effort.These are 4 sates of cache control and how this impacts request bundling:
Default cache control or session cache control settings will bundle requests so that middleware only runs once for all loaders.
Private and public cache control settings will have any middleware run for each request. This should have a low impact as requests would be cached.
Code examples
This would be the new session based cache control settings. Qwik will automatically refetch the data after 600 seconds.
The signature for the cacheControl function would look like this:
Links / References
No response
Beta Was this translation helpful? Give feedback.
All reactions