Stability: cache-control at origin + non-hanging startup

Intermittent blank screens / long "Gathering the good news…" — two fixes:

Origin cache headers (Caddyfile, deployed separately): content-hashed
/_app/immutable/* → max-age=31536000, immutable; everything else (HTML shell,
service worker, version manifest, webmanifest, word lists, icons) → no-cache,
so a deploy can't leave a stale shell/SW pinned. (Cloudflare's 4h Browser Cache
TTL still overrides this until its dashboard setting is switched to "Respect
Existing Headers" — that's the actual root cause.)

App startup hardening:
* getJSON now has a 10s AbortController timeout — a stuck request can never hang
  the loading state forever.
* Home onMount loads moods+categories in parallel then the view, with loading
  ALWAYS cleared in finally; lanes/families dropped to non-blocking decoration.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
jay
2026-06-10 22:13:21 -04:00
parent a52226ce61
commit bd2a477570
2 changed files with 27 additions and 11 deletions
+10 -4
View File
@@ -1,7 +1,13 @@
export async function getJSON(url) {
const r = await fetch(url);
if (!r.ok) throw new Error((await r.text().catch(() => '')) || r.statusText);
return r.json();
export async function getJSON(url, { timeout = 10000 } = {}) {
const ctrl = new AbortController();
const t = setTimeout(() => ctrl.abort(), timeout); // never hang on a stuck request
try {
const r = await fetch(url, { signal: ctrl.signal });
if (!r.ok) throw new Error((await r.text().catch(() => '')) || r.statusText);
return await r.json();
} finally {
clearTimeout(t);
}
}
export async function postJSON(url, body) {