Skip to content

fix: bound ipns cache-control to record eol#1166

Open
lidel wants to merge 1 commit into
mainfrom
fix/ipns-cache-control-expiry
Open

fix: bound ipns cache-control to record eol#1166
lidel wants to merge 1 commit into
mainfrom
fix/ipns-cache-control-expiry

Conversation

@lidel
Copy link
Copy Markdown
Member

@lidel lidel commented Jun 3, 2026

Problem

GET /routing/v1/ipns/{name} set max-age to the record TTL and stale-while-revalidate/stale-if-error to the full remaining validity, so the stale-serving window (max-age + stale) extended past the record's EOL by up to max-age. During that overshoot a cache (a CDN such as the one in front of delegated-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-age alone could cross EOL and serve an expired record as fresh.

Fix

  • Cap max-age to the record's remaining validity.
  • Size stale-while-revalidate/stale-if-error to the validity left after max-age, so max-age+stale never crosses EOL.
  • Return Cache-Control: no-store for an already-expired record.

No cache reuses an IPNS response past the point where the record is still cryptographically valid.

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.
@lidel lidel requested a review from achingbrain June 3, 2026 15:36
@lidel lidel requested a review from a team as a code owner June 3, 2026 15:36
@codecov
Copy link
Copy Markdown

codecov Bot commented Jun 3, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 63.41%. Comparing base (fc2837e) to head (bd30921).

Impacted file tree graph

@@            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     
Files with missing lines Coverage Δ
routing/http/server/server.go 78.62% <100.00%> (+0.79%) ⬆️

... and 6 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@achingbrain
Copy link
Copy Markdown
Member

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.

3 participants