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

use(Lazy)AsyncData not caching when used in composables #15688

Closed
tofi92 opened this issue Dec 8, 2022 · 4 comments
Closed

use(Lazy)AsyncData not caching when used in composables #15688

tofi92 opened this issue Dec 8, 2022 · 4 comments

Comments

@tofi92
Copy link

tofi92 commented Dec 8, 2022

Environment

  • Operating System: Windows_NT
  • Node Version: v16.15.0
  • Nuxt Version: 3.0.0
  • Nitro Version: 1.0.0
  • Package Manager: yarn@1.22.18
  • Builder: vite
  • User Config: runtimeConfig, modules, css
  • Runtime Modules: @pinia/nuxt@0.4.6, @vueuse/nuxt@9.6.0, @nuxtjs/tailwindcss@6.1.3
  • Build Modules: -

Reproduction

https://stackblitz.com/edit/github-ugv5yg-sfrist (Stable)
https://stackblitz.com/edit/github-ugv5yg-ijhnxn (rc.11)

Describe the bug

Using useAsyncData (or useLazyAsyncData) with a fixed key in a composable fetches data for every component it is used in. Expected behaviour would be that it only fetches the data once. That was the case with rc.11 (my last rc before release), but not with rc14/release. I can't see any documentation mentioning this or any breaking change referencing this behavior.

Additional context

No response

Logs

No response

Copy link
Member

This is a deliberate change - see nuxt/framework#8885.

@danielroe danielroe closed this as not planned Won't fix, can't repro, duplicate, stale Dec 8, 2022
@tofi92
Copy link
Author

tofi92 commented Dec 8, 2022

Ah alright, did not see that. Thanks!

@cawa-93
Copy link
Contributor

cawa-93 commented Jan 4, 2023

@danielroe This is very confusing. This is not mentioned anywhere in the documentation as I can see. On the contrary, it seems that requests with the same key between different pages should not be repeated but should use a shared cache. But it is not so.

Is this a bug that will be fixed in the future or is it expected behavior now? This is important, because in rc11, when performing certain mutations, I had to manually call clearNuxtData to clear related cache.

In the Stable release, there is no need to clear the cache yourself, because when switching between pages, although the cached data exists for the requested key, it is not used.

So can I delete all cache cleanup operations? Will the behavior of the load change again in the future and return to the way it was in rc11? 😵

@danielroe
Copy link
Member

No, it was a deliberate change to remove caching behaviour by default. In future it is possible we might provide a way for users to opt-in to caching, but I am not expecting a breaking change.

@danielroe danielroe added the 3.x label Jan 19, 2023
@danielroe danielroe transferred this issue from nuxt/framework Jan 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants