fix: bound ipns cache-control to record eol#1166
Open
lidel wants to merge 1 commit into
Open
Conversation
max-age plus stale-while-revalidate could extend past an IPNS record's EOL, letting caches serve an expired record that then fails validation. Cap max-age to the remaining validity and size the stale window to whatever validity is left, so max-age+stale never crosses EOL. An already-expired record is returned with Cache-Control: no-store.
Codecov Report✅ All modified and coverable lines are covered by tests. @@ Coverage Diff @@
## main #1166 +/- ##
==========================================
+ Coverage 63.39% 63.41% +0.02%
==========================================
Files 268 268
Lines 26967 26973 +6
==========================================
+ Hits 17096 17106 +10
+ Misses 8147 8144 -3
+ Partials 1724 1723 -1
... and 6 files with indirect coverage changes 🚀 New features to boost your workflow:
|
gammazero
approved these changes
Jun 3, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
GET /routing/v1/ipns/{name}setmax-ageto the record TTL andstale-while-revalidate/stale-if-errorto the full remaining validity, so the stale-serving window (max-age+ stale) extended past the record's EOL by up tomax-age. During that overshoot a cache (a CDN such as the one in front ofdelegated-ipfs.dev, or a browser/Helia HTTP cache) serves a record whose signature has already expired; a validating consumer then rejects it, which surfaced as sporadic 500s in the service-worker gateway. When the record TTL exceeded the remaining validity,max-agealone could cross EOL and serve an expired record as fresh.Fix
max-ageto the record's remaining validity.stale-while-revalidate/stale-if-errorto the validity left aftermax-age, somax-age+stale never crosses EOL.Cache-Control: no-storefor an already-expired record.No cache reuses an IPNS response past the point where the record is still cryptographically valid.