fix(api): /api/v1/capabilities Cache-Control + must-revalidate (BUG-API-039/311)#193
Merged
Merged
Conversation
…PI-039/311)
/api/v1/capabilities is dashboard-hit on every navigation (sidebar tile
counts, billing card, settings page) but the tier matrix is immutable
for the life of the running pod — it only changes on a plans.yaml edit
+ redeploy. Without a Cache-Control hint each nav re-fetched the full
~4 KB matrix; sidebar fanout meant 4-6 redundant fetches per nav
(see BUG-DASH-016).
Stamp `public, max-age=60, must-revalidate` so browser/edge caches serve
the matrix for a minute while still re-validating on expiry. The rule-23
deploy cycle flips the /healthz commit_id which invalidates the proxy
cache shortly after a plans.yaml change ships, so the 60s ceiling is
well below the user-observable change window.
Coverage block:
Symptom: /api/v1/capabilities uncached, no Cache-Control (BUG-API-039)
/api/v1/capabilities no Last-Modified (BUG-API-311)
Enumeration: rg -F 'capabilities' internal/handlers/capabilities.go
rg -F 'NewCapabilitiesHandler' internal/router/router.go
(1 emit site — internal/handlers/capabilities.go Get)
Sites found: 1
Sites touched: 1
Coverage test: TestCapabilities_CacheControlPublicMaxAge60 asserts the
exact `public, max-age=60, must-revalidate` string on
the 200 path so a future deletion fails before merge.
Live verified: pending auto-deploy + `curl -I https://api.instanode.dev/api/v1/capabilities | grep -i cache-control`
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
0e5fa78 to
6dba22a
Compare
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.
Summary
Coverage block
```
Symptom: /api/v1/capabilities uncached, no Cache-Control (BUG-API-039)
/api/v1/capabilities no Last-Modified (BUG-API-311)
Enumeration: rg -F 'capabilities' internal/handlers/capabilities.go (1 emit Get)
rg -F 'NewCapabilitiesHandler' internal/router/router.go
Sites found: 1
Sites touched: 1
Coverage test: TestCapabilities_CacheControlPublicMaxAge60 asserts the exact
'public, max-age=60, must-revalidate' string on the 200 path.
Live verified: pending auto-deploy + curl -I https://api.instanode.dev/api/v1/capabilities | grep -i cache-control
```
Inbox reference
Caching + consistency tradeoff (per memory rule)
Test plan
🤖 Generated with Claude Code