Thanks to visit codestin.com
Credit goes to github.com

Skip to content

docs: document client-side caching patterns for getCachedData#34304

Open
benjamincanac wants to merge 2 commits intonuxt:mainfrom
benjamincanac:docs/client-side-caching-guide
Open

docs: document client-side caching patterns for getCachedData#34304
benjamincanac wants to merge 2 commits intonuxt:mainfrom
benjamincanac:docs/client-side-caching-guide

Conversation

@benjamincanac
Copy link
Member

πŸ”— Linked issue

Related: #24271 #31816

πŸ“š Description

With Nuxt 4 defaulting to purgeCachedData and granularCachedData, data is no longer cached across client-side navigations. I ran into this on Volta and had to dig through the source to understand what changed.

This PR adds a "Client-side Caching" section to the data fetching guide with two patterns (cache until refresh and stale-while-revalidate), updates the getDefaultCachedData snippet in the API docs to match the actual source, and adds a migration step in the upgrade guide.

@bolt-new-by-stackblitz
Copy link

Review PR in StackBlitz Codeflow Run & review this pull request in StackBlitz Codeflow.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 10, 2026

Walkthrough

This pull request updates Nuxt documentation to reflect changes to getCachedData semantics: the default implementation no longer preserves data across client-side navigations, only providing cached values during SSR hydration or when payloadExtraction is enabled. Docs add an opt-in mechanism to persist client-side data via a custom getCachedData, describe a new ctx.cause parameter (e.g. refresh:manual/refresh:hook) for conditional cache bypassing, and present two caching patterns (cache-until-refresh and stale-while-revalidate) with examples and guidance. Changes touch getting-started, upgrade notes, and composables API docs.

Possibly related PRs

πŸš₯ Pre-merge checks | βœ… 3
βœ… Passed checks (3 passed)
Check name Status Explanation
Title check βœ… Passed The title clearly and specifically describes the main change: documenting client-side caching patterns for getCachedData, which aligns with the primary objective of the pull request.
Description check βœ… Passed The description is directly related to the changeset, providing context about why the changes were made (Nuxt 4 defaults affecting caching) and detailing what was added (caching patterns, API docs updates, migration guidance).
Docstring Coverage βœ… Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
πŸ§ͺ Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

No actionable comments were generated in the recent review. πŸŽ‰


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❀️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@OrbisK
Copy link
Member

OrbisK commented Feb 10, 2026

There is also a related topic that we could cover here:

image

By default the old keys data is purged on key change. However this does not happen if there is a custom cached function.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants