Skip to content

fix(cache): respect staleMaxAge option - #2606

Closed
cjpearson wants to merge 1 commit into
nitrojs:v2from
cjpearson:fix/respect-stale-max-age
Closed

cjpearson wants to merge 1 commit into
nitrojs:v2from
cjpearson:fix/respect-stale-max-age

Conversation

@cjpearson

Copy link
Copy Markdown
Contributor

🔗 Linked issue

#2164

❓ 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

This change ensures that stale responses are only used if they have not exceeded the period defined in staleMaxAge.

📝 Checklist

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

@TheAlexLichter

TheAlexLichter commented Jul 23, 2024 •

Copy link
Copy Markdown
Member

Used it in my project locally and it worked fine 👍🏻

@TheAlexLichter TheAlexLichter added the bug Something isn't working (PRs; issues use the Bug type) label Jul 23, 2024
@pi0 pi0 added the cache Caching, ISR and SWR label Sep 20, 2024
@pi0
pi0 self-requested a review as a code owner October 10, 2024 12:34
@reslear

This comment was marked as off-topic.

@cjpearson
cjpearson force-pushed the fix/respect-stale-max-age branch from 7fce524 to 4c04aa4 Compare July 25, 2025 14:43
@vercel

vercel Bot commented Jul 25, 2025

Copy link
Copy Markdown

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

A member of the Team first needs to authorize it.

@pi0

pi0 commented Mar 19, 2026

Copy link
Copy Markdown
Member

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

  • staleMaxAge is respected at read time — entries beyond maxAge + staleMaxAge are fully expired and not served stale (cache.ts#L88-L110)
  • Stale entries are evicted from storage when background revalidation fails

See unjs/ocache#9

@pi0 pi0 added the v2 label Apr 2, 2026
@pi0 pi0 closed this Jul 8, 2026
@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

bug Something isn't working (PRs; issues use the Bug type) cache Caching, ISR and SWR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants