Skip to content

fix: swr cache invalidation - #4060

Closed
Flo0806 wants to merge 4 commits into
nitrojs:v2from
Flo0806:fix/swr-cache-invalidation
Closed

Flo0806 wants to merge 4 commits into
nitrojs:v2from
Flo0806:fix/swr-cache-invalidation

Conversation

@Flo0806

@Flo0806 Flo0806 commented Feb 26, 2026

Copy link
Copy Markdown

Hi @pi0!

🔗 Linked issue

fixes: nuxt/nuxt#34189

❓ Type of change

  • 📖 Documentation (updates to the documentation, readme, or JSdoc annotations)
  • 🐞 Bug fix (a non-breaking change that fixes an issue)
  • 👌 Enhancement (improving an existing functionality like performance)
  • ✨ New feature (a non-breaking change that adds functionality)
  • 🧹 Chore (updates to the build process or auxiliary tools and libraries)
  • ⚠️ Breaking change (fix or feature that would cause existing functionality to change)

📚 Description

When a cached api endpoint correctly returns a 404 response, the cached entry for that page is not removed or invalidated. This can result in stale content being served from cache even after the page has been unpublished. Now on such errors the cache will be correct invalidated and deleted if needed.

Testing

Added integration tests for it.

📝 Checklist

  • I have linked an issue or discussion.
  • I have updated the documentation accordingly.

@Flo0806
Flo0806 requested a review from pi0 as a code owner February 26, 2026 18:42
@vercel

vercel Bot commented Feb 26, 2026

Copy link
Copy Markdown

@Flo0806 is attempting to deploy a commit to the Nitro Team on Vercel.

A member of the Team first needs to authorize it.

@coderabbitai

coderabbitai Bot commented Feb 26, 2026

Copy link
Copy Markdown
Contributor

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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.

@pi0

pi0 commented Mar 19, 2026

Copy link
Copy Markdown
Member

This is now addressed in unjs/ocache (used by Nitro v3):

  • When SWR background revalidation throws, the stale cache entry is evicted from storage
  • When SWR background revalidation returns a value that fails validation, the stale cache entry is evicted from storage

See unjs/ocache#9

@pi0 pi0 added the v2 label Apr 2, 2026
@pi0 pi0 closed this Jul 8, 2026
@Flo0806
Flo0806 deleted the fix/swr-cache-invalidation branch July 8, 2026 17:21
@pi0x pi0x removed the v2 label Nov 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants