Skip to content

feat: use staleMaxAge to compute cache item TTL - #3263

Closed
emmanuelgautier wants to merge 1 commit into
nitrojs:mainfrom
emmanuelgautier:use-stalemaxage-setitem-ttl
Closed

emmanuelgautier wants to merge 1 commit into
nitrojs:mainfrom
emmanuelgautier:use-stalemaxage-setitem-ttl

Conversation

@emmanuelgautier

Copy link
Copy Markdown

🔗 Linked issue

#3110

❓ 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 update modifies the cache TTL calculation to use the staleMaxAge options. TTL is undefined when swr is enabled. With this change, cache items will now expire after maxAge + staleMaxAge.

📝 Checklist

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

@pi0

pi0 commented Mar 19, 2026

Copy link
Copy Markdown
Member

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

Storage TTL is set to `maxAge + staleMaxAge` when SWR is enabled, so entries are properly evicted by the storage backend.

See https://github.com/unjs/ocache/blob/main/src/cache.ts#L146-L149

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.

2 participants