Skip to content

feat(gateway): serve cache hits past a spent allowance or a missing capability - #2906

Closed
alpergundogdu wants to merge 1 commit into
gateway-cachefrom
gateway-cache-past-gates
Closed

alpergundogdu wants to merge 1 commit into
gateway-cachefrom
gateway-cache-past-gates

Conversation

@alpergundogdu

Copy link
Copy Markdown
Contributor

Stacked on #2905; the base moves to main once it merges. This closes the gap #2905 left: a cache hit costs nothing, yet a spent allowance or a page no capability covers still got a 402 before the gateway looked at the cache.

What changes

  • Hits get past both gates. When the public allowance is spent, or a loopback page has no covering capability, paid first tries cached_only. That serves a blob, a bundle entry or a site's index.html when the cache holds every byte of the response, at a size the gateway knows with no pull. An empty blob and a 416 are answered too, since they cost nothing. Anything else gets the same 402 as before: a HEAD, a listing, or a byte the cache lacks.
  • Manifests come from the cache. manifest() reads a manifest the cache holds whole, within the manifest cap, before it pulls one, and keeps it as a pulled manifest (or a not-a-manifest verdict). A site entry is thus a hit after a restart too, with no paid manifest pull.
  • A site's / checks the cache. index() checks for a hit before it streams index.html, as entry() and blob() already do.
  • Docs: adr/appendix-gateway.md § Cache and the gateway module doc.

Tests

  • A spent allowance still serves a cached blob, and refuses an uncached one with 402.
  • With the allowance spent, a site's entry and its / both come from the cache, manifest included, with nothing pulled.
  • A loopback page with no capability gets a cached blob, and a 402 naming the missing capability for an uncached one.
  • cargo nextest run -p decdn-cli, the anvil-e2e gateway journeys, cargo clippy --workspace --all-targets --all-features with warnings denied, cargo doc, cargo fmt --check.

🤖 Generated with Claude Code

…apability

A spent allowance or a page no capability covers now answers from the
cache when it holds every byte of the response, since a hit costs
nothing. Manifests the cache holds whole are read from it with no pull,
and a site's index.html checks the cache as entries do.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@alpergundogdu

Copy link
Copy Markdown
Contributor Author

Combined into #2908, which carries this PR's commits together with the rest of the stack so they land as one.

@alpergundogdu
alpergundogdu deleted the gateway-cache-past-gates branch November 18, 2026 11:23
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.

1 participant