-
Notifications
You must be signed in to change notification settings - Fork 19
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
Client side request are not cached #53
Comments
The module is specifically only made for SSR caching. Especially the unstorage dependency would have to be included in the client bundle for a seamless experience, which would not be that great. And it would then also only be compatible with the memory driver. Of course it would be possible to hardcode a memory cache into the client side code of the composable. On the client side you already have Nuxt's own utilities such as useState or useAsyncData available to implement your own caching. For a seamless experience, useDataCache would have to pass the cached data back to the client as a payload so it's available on hydration. However, when used together with useState or useAsyncData, the same data would then be passed as payload twice. However, I do see the value of having a single |
Thank you for your quick response. The problem with useState and useAsyncData is that at the moment it should do at least one time a graphql call on client side. If the data already persist in the cache i'd like to avoid that graphql call. I don't know if my thought is right but I hope it can be useful |
Yeah I know exactly what you mean! Just using useAsyncData out of the box will only return a cached value on hydration. You'd have to define your own |
Thank you and sorry again. I know that this question can riuslt annoying. Do you think that a server endpoint that handle this for me can be a good solution? Or do you have an alternative idea? 🙏 |
You can pass a By default, the Note that this only works on the client side. On the server these methods are not called, if I'm not mistaken. |
Wow, simpler than i thought. It works fine with subsequent calls but in the client at the first access between one page and another it is always a new graphql when I am sure that the data has already been stored with the addToCache function.
This is my custom useAsyncData |
I would try to move |
Wow! Incredible work. Thank you ! 🙏 |
As this has already been released in the last release, I'm going to close this issue. |
Hi, sorry for the disturb.
I'm using the data cache api and I was wondering if it was the normal functioning of the plugin that the client side returns undefined as the cached value.
Is there a way to make this work on the client side too?
The text was updated successfully, but these errors were encountered: