Commit bc7cc64
fix(api): /api/v1/capabilities Cache-Control + must-revalidate (BUG-API-039/311) (#193)
/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>1 parent d25ea33 commit bc7cc64
2 files changed
Lines changed: 41 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
191 | 191 | | |
192 | 192 | | |
193 | 193 | | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
194 | 211 | | |
195 | 212 | | |
196 | 213 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
283 | 283 | | |
284 | 284 | | |
285 | 285 | | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
286 | 310 | | |
287 | 311 | | |
288 | 312 | | |
| |||
0 commit comments