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

fix(nuxt): initialCache: false cache not deleted #7265

Closed
wants to merge 18 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 10 additions & 4 deletions packages/nuxt/src/app/composables/asyncData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -198,11 +198,17 @@ export function useAsyncData<
if (options.watch) {
watch(options.watch, () => asyncData.refresh())
}
const off = nuxt.hook('app:data:refresh', (keys) => {
if (!keys || keys.includes(key)) {
return asyncData.refresh()
const off = () => {
// When initialCache is false, the memory will be deleted, and the memory will be cleaned up to improve performance
if (!options.initialCache) {
delete nuxt._asyncData[key]
}
})
nuxt.hook('app:data:refresh', (keys) => {
if (!keys || keys.includes(key)) {
return asyncData.refresh()
}
})
}
if (instance) {
onUnmounted(off)
}
Expand Down