oliver-zehentleitner / maity
performance: the dashboard's static files are revalidated (no-cache + ETag) instead of no-store
tsk-pcw785rhymyg Done An agent
Owner decision (Oliver, req-s246xb6k1mpp option A, 2026-11-08): the dashboard's static files may be cached.
Today every file the hub serves for the dashboard (index.html, 93 scripts, 2 CSS, fonts; 691 KB gzip) goes out with cache-control: no-store — the middleware default recorded in hub/context/images.md (96d70040: "no-store unless listed"). Every reload fetches all 97 again (eyq5, tsk-fxjtwmkc4md5).
Task:
- Plan note first: which paths (web/js, web/css, fonts, /assets/), the exact headers (
Cache-Control: no-cache+ strongETag, 304 onIf-None-Match; or versioned names + long max-age if that is cleaner — say why), what stays no-store (every API answer with private data, index.html if it embeds anything per user), and how a deploy reaches browsers at once. - Update the recorded rule (context entry with the reason: owner decision, files hold no private data).
- Tests: 304 on a matching ETag, 200 with body after a change, API routes still no-store.
Boundary: static dashboard files only; no API answer becomes cacheable in this card; no contract change (if one is needed, stop and tell me). The PR watch design (tsk-rhgzcjqcfb9s) waits for Oliver; r6fe still comes after #1509 — this card goes before r6fe.
Notes
An agent · Nov 8, 2026, 17:19 UTC
Plan: the dashboard's static files are revalidated, not `no-store` (maity-coder-claude-001#hrjz; main 4564ec5259e980daed00588c544f6c109e205a2e; req-s246xb6k1mpp A)
A contract sentence is needed first, so I stop here as the Boundary says. docs/api.md §1 (:98-116) gives
no-storefor every response and lists the exceptions: the images, attachments, the contract, the badge, public pictures, and the app shell (no-cache). The dashboard's files under/assets/are not on that list, and §16.11 (:18450-18470) gives caching only for/assets/landing/. Proposed sentences for Oliver:- §1, after "…the app shell (§16.11), which is
no-cache: it holds no data and must follow a deploy": "and the dashboard's files under `/assets/` (§16.11), `no-cache` with an `ETag` of the file's content, for the same reason." - §16.11, after the shell's paragraph: "The dashboard's files under `/assets/` (`css/`, `js/`, `brand/`, `vendor/`) are answered `Cache-Control: no-cache` with a strong `ETag` taken from the file's content; a request whose `If-None-Match` matches gets `304` without a body."
What exists:
shell.AssetFiles(a StarletteStaticFilesovercss/ js/ brand/ vendor/) already sends anETagand answers304. The middleware (middleware.py:563-571) then overwritesCache-Controlwithno-store, because the route sets none.no-cacheis already onROUTE_CACHE. The shell is alreadyno-cache(SHELL_HEADERS).Change (hub only, once the contract is in):
AssetFilesanswersCache-Control: no-cacheon its200and304.- The ETag is
"<sha256 of the content, first 32 hex>", cached per process by (path,st_mtime_ns, size). This replaces Starlette's MD5 of mtime and size: an image built with normalised file times could otherwise keep the old ETag for a changed file of the same size. Last-Modified is dropped so that only the ETag decides. - Unchanged:
- every
/api/v1/…answer and the 404s under/assets/stayno-store; - the shell stays
no-cache, since it is per request (Vary: Cookie, a public page inside it, the social image's address); /assets/landing/keeps its own rule.
A deploy reaches browsers at once:
no-cachemakes the browser revalidate on every use. A changed file has a new ETag, so the answer is200with the new file. During a rolling update, two pods with different files give different ETags, which is also a200.Gain: a reload sends the same 97 requests, but each answer is a
304of a few hundred bytes instead of 691 KB gzip. eyq5's tsk-fxjtwmkc4md5 can measure it before and after.Versioned names with a long max-age (not this card): the hub would rewrite the shell's 93
<script src>and 2<link href>to?v=<digest>and answer themimmutable, as/assets/landing/already does. A reload would then send no requests for them. That is cleaner for speed, but it needs a rewrite inshell_document, has to leaveurl()references inside the CSS onno-cache, and is also a contract change. I propose it as a follow-up card once this one's numbers are in.Context: update 96d70040 (images.md) with the new exception, plus a new entry in
hub/context/with the reason (the owner's decision, and the files hold no private data) and the rejected alternatives: Starlette's mtime ETag, and versioned names for now.Tests:
200withno-cacheand an ETag, then304on a matchingIf-None-Match.- Same size and same mtime with changed content gives a new ETag and a
200with the body. /api/v1/…staysno-store, as do a 404 under/assets/and/assets/landing/unchanged.- The shell is unchanged.
There is also a changelog fragment. No migration.
- §1, after "…the app shell (§16.11), which is