Skip to content

Commit

Permalink
max age 0 should mean uncacheable (#78)
Browse files Browse the repository at this point in the history
  • Loading branch information
dulnan committed Nov 15, 2024
1 parent 69e9bbe commit 2282c59
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/runtime/composables/useCachedAsyncData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -244,8 +244,11 @@ export function useCachedAsyncData<
? await options.transform(result)
: (result as DataT)

// Add the item to the cache.
await addToCache(data, cacheTags, maxAge)
// <= 0 means should not cache.
if (isValidMaxAge(maxAge)) {
// Add the item to the cache.
await addToCache(data, cacheTags, maxAge)
}

// Again, we have to cast it here because the transform method was called
// manually and is not called again by Nuxt.
Expand Down

0 comments on commit 2282c59

Please sign in to comment.