Skip to content

fix(cache): respect staleMaxAge option#2606

Open
cjpearson wants to merge 1 commit intonitrojs:v2from
cjpearson:fix/respect-stale-max-age
Open

fix(cache): respect staleMaxAge option#2606
cjpearson wants to merge 1 commit intonitrojs:v2from
cjpearson:fix/respect-stale-max-age

Conversation

@cjpearson
Copy link
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
Copy link
Member

TheAlexLichter commented Jul 23, 2024

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

@TheAlexLichter TheAlexLichter added the bug Something isn't working label Jul 23, 2024
@pi0 pi0 added the cache 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
Copy link

vercel bot commented Jul 25, 2025

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

A member of the Team first needs to authorize it.

@pi0
Copy link
Member

pi0 commented Mar 19, 2026

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

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

Labels

bug Something isn't working cache

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants