Migrate Github to Cloudflare for Worker AI and Speed
Migrated Traffic Torch's static site from GitHub Pages (US-only origin) to Cloudflare Pages (edge-cached). Same Worker routes still handle dynamic pages; the shell they fetch now comes from the edge instead of a single US region. TTFB on the static site dropped from ~180ms to ~130ms edge-HIT.
Why
Traffic Torch is a large static site (HTML + Vite-bundled assets) plus a few Cloudflare Workers that render dynamic pages (profiles, torches, community feeds, sitemaps, OG images).
Static was hosted on GitHub Pages — single-region, US-based origin. From Australia, cold TTFB was ~250ms. Worse: every wrangler deploy of a worker purged Cloudflare's edge cache, forcing cold re-fetches from the US origin. GH Pages also had ~10-min TTLs that fought our fast iteration.
Target
Move the static shell to Cloudflare Pages so it's edge-cached globally. Keep Workers as-is - they still render dynamic routes. Only the shell origin changes.
Architecture
Before:
traffictorch.net → GH Pages (static)
Worker routes on the same zone → torches-page-render
Worker fetched shell from SITEORIGIN = "https://traffictorch.net" (which was GH Pages)
After:
traffictorch.net → CF Pages project traffic-torch
Same worker routes on the same zone (Workers always win over Pages for matched paths)
Worker fetches shell from edge-cached Pages
The tricky bit: dual hosting during cutover
You can't detach traffictorch.net from GH Pages at Cloudflare without losing the apex. Solution: run both in parallel.
Deploy static site to a Pages preview (cf-migration.traffic-torch.pages.dev)
Diff every path against prod (curl status + size + TTFB)
Attach preview.traffictorch.net to Pages as a custom domain
Flip SITEORIGIN on the torches worker to preview, verify /torcher/ renders
Detach domain from the old traffic-torch-functions Pages project, attach to traffic-torch
Flip SITEORIGIN back to traffictorch.net (now edge-served)
Keep gh-pages branch as fallback for atleast 48h or forever
Key decisions
Direct upload, not Git integration. No build step in Cloudflare. Repo has zero-dep static output; deploying from dist/ via wrangler pages deploy is faster and gives exact control over what ships. Matches how we already deploy Workers.
Deploy from dist/, not repo root. npm run build (a Vite build + a shell…