414a4c4b8b
Cloudflare is DNS-only (grey-cloud) for upbeatbytes.com — no proxy/CDN/edge — so the warm() step (curl every chunk + key routes through the public domain) wasn't priming any edge; it just GET every asset from the already-fast static origin, generating thousands of internal-origin requests per deploy (the "traffic spike" in the logs). Removed it. Kept the valuable part: chunks-before-shell ordering, 14-day chunk grace, service-worker last. No change for visitors. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
31 lines
1.6 KiB
Bash
Executable File
31 lines
1.6 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# Sync the built static site to the live root in an order that avoids deploy-race
|
|
# blank screens. rsync isn't atomic, so a naïve `rsync --delete` can briefly serve
|
|
# a NEW index.html that points at chunks not synced yet (→ failed load), or delete
|
|
# old chunks an in-flight client still needs. So the order is:
|
|
# 1. new hashed chunks first, and DON'T prune old ones (14-day grace window)
|
|
# 2. other static assets (version.json, icons…), pruning removed files
|
|
# 3. the shell HTML — only once its chunks exist
|
|
# 4. the service worker last — a returning client adopts it only after the rest
|
|
# Old immutable chunks are pruned after the grace window to bound disk growth.
|
|
#
|
|
# NOTE: there is intentionally NO edge cache-warming. Cloudflare is DNS-only
|
|
# (grey-cloud) for upbeatbytes.com — no proxy/CDN/POP — so warming would just GET
|
|
# every asset from the residential origin (already µs-fast static): a no-op that
|
|
# generated lots of internal request volume. Removed 2026-06-29.
|
|
set -euo pipefail
|
|
src="$1"; site="$2"
|
|
|
|
# 1. New hashed chunks first (old ones kept — 14-day grace for in-flight clients).
|
|
rsync -a "$src/_app/immutable/" "$site/_app/immutable/"
|
|
|
|
# 2. Other static assets (prune removed files), then 3. the shell, then 4. the SW.
|
|
rsync -a --delete \
|
|
--exclude='_app/immutable/***' --exclude='index.html' --exclude='service-worker.js' \
|
|
"$src/" "$site/"
|
|
rsync -a "$src/index.html" "$site/index.html"
|
|
rsync -a "$src/service-worker.js" "$site/service-worker.js"
|
|
|
|
# Bound disk growth: prune immutable chunks older than the grace window.
|
|
find "$site/_app/immutable" -type f -mtime +14 -delete 2>/dev/null || true
|