Reliability/speed: warm CF cache on deploy + lighten SW (no precache storm)

The post-deploy blank/slow load: new hashed chunks weren't in Cloudflare yet, so
the first visitor pulled them cold from the residential origin — AND the service
worker simultaneously precached ~30 of those cold assets (a request storm),
pushing past the 7s boot timeout.

* sync-static.sh now warms the CF edge cache (fetches every immutable asset
  through the public domain) so the first visitor gets HITs, not cold-origin.
* Service worker no longer bulk-precaches on install (the browser already caches
  immutable assets for a year); it caches the shell + assets lazily as used. No
  more storm.
* Boot-recovery timeout 7s → 10s so a merely-slow load doesn't flash the card.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
jay
2026-06-11 12:20:29 -04:00
parent 9e387a0a09
commit 370d62270b
3 changed files with 34 additions and 20 deletions
+7
View File
@@ -18,3 +18,10 @@ rsync -a --delete \
rsync -a "$src/index.html" "$site/index.html"
rsync -a "$src/service-worker.js" "$site/service-worker.js"
find "$site/_app/immutable" -type f -mtime +14 -delete 2>/dev/null || true
# Warm the Cloudflare edge cache: fetch every immutable asset through the public
# domain so the FIRST real visitor after a deploy gets cache HITs instead of slow
# cold fetches from the (residential) origin — the post-deploy blank/slow-load cause.
echo " warming edge cache…"
find "$site/_app/immutable" -type f \( -name '*.js' -o -name '*.css' \) -printf '/_app/immutable/%P\n' \
| xargs -P 8 -I{} curl -fsS -o /dev/null --max-time 20 "https://upbeatbytes.com{}" 2>/dev/null || true