You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
SWR cached routes won't ever update content if response is empty or response is 404 #1992
Start the site either with npm run dev or npm build && node .output/server/index.mjs
Navigate to the add-value-to-storage endpoint
Navigate to the swr endpoint (will see nitro: is-awesome)
Navigate to the not-swr endpoint (will see nitro: is-awesome)
Navigate to the remove-value-from-storage endpoint
Navigate to the not-swr route and refresh until the cache expires
Will eventually get a blank response
Navigate to the swr endpoint
It'll continue to return the nitro: is-awesome response indefinitely.
Describe the bug
Routes cached by SWR cannot be updated to return empty/404 values without fully clearing the cache.
Description
We currently have a high-traffic Nuxt 3 site that's backed by a CMS. We have the pages and a Nuxt/Nitro API set to cache with SWR for 60 minutes.
When content editors delete a page, our CMS API will return null, which is what we'd expect our Nitro API to return. However, if the nitro API returns null or manually returns a 404 response, Nitro never seems to invalidate the SWR cache. This means we can't delete pages without manually clearing entries from the cache. This feels unexpected since there might be valid reasons for an API to return a 404 or 204 response.
Activity
infabo commentedon Dec 5, 2025
Why is this issue stale? This is a real-world issue.
pi0 commentedon Mar 19, 2026
This is now fixed in unjs/ocache (used by Nitro v3):
This prevents the "stale forever" behavior where deleted content keeps being served.
See unjs/ocache#9
fix(cache): evict stale entry from storage on SWR revalidation failure