Summary
Origin server-side rendering alone cannot beat network physics across continents. Even if a Go handler renders a page in 2 milliseconds, a visitor in Sydney hitting a single origin in Frankfurt still pays 250+ milliseconds just in TCP, TLS, and round-trip latency.
In Yin Business, we pair a Go web render engine with a thin Cloudflare Worker edge layer and object storage (R2). Public static and ISR routes answer directly from edge cache or R2 with zero origin CPU, while authenticated or dynamic routes fall through cleanly to the origin.
Designing the fast path with route manifests
When a tenant publishes a site, the Go web engine (bis-web-engine) pre-compiles every static route into complete semantic HTML shells with resolved theme tokens and deferred behaviour scripts. Alongside the HTML objects, it writes a tiny JSON manifest keyed by hostname (manifests/<host>.json).
Every incoming request at the edge follows the same deterministic path:
- 1. Hostname lookup: The Cloudflare Worker reads the domain's manifest (cached in edge memory with a short TTL) to learn the project ID, environment, route mode (
static,isr, ordynamic), storage key, and current data epoch. - 2. Edge cache & R2 hit: For public static routes, the Worker checks the Cloudflare Cache API first and falls back to R2 on a cold PoP. The origin Go server never sees the request, keeping TTFB under 15ms and origin egress at zero.
- 3. Epoch-based invalidation: Instead of issuing slow, brittle CDN purge-by-URL calls across dozens of routes, publishing bumps a monotonic epoch timestamp in the manifest. Cache keys include the epoch, so stale HTML becomes unreachable the instant the manifest updates.
- 4. Dynamic & authenticated fallthrough: Routes marked
dynamic—or requests carrying an active session cookie for member-only pages—bypass the static cache and proxy straight to the origin ingress gateway.
Edge worker + origin fallback flow
Multi-tenant edge- Cloudflare WorkerEdge
- Domain manifestKV/JSON
- R2 static HTML ($0 origin)HIT
- Go render engine (:3000)MISS / Auth
Practical lessons from multi-tenant edge caching
The most dangerous mistake in multi-tenant web infrastructure is treating edge caching as an afterthought or keying cached HTML on request.url alone. Three lessons shaped our current design:
- Never cache personalized state at the CDN edge: Trying to serve logged-in dashboards from shared edge cache inevitably leads to session-bleed bugs when a header or cookie varies unexpectedly. Splitting routes explicitly by mode in the manifest keeps public pages blazing fast and private pages strictly per-request.
- Pre-compute 404s and redirects per tenant: Missing routes can easily become an origin DDoS vector when bots crawl random paths. Storing each tenant's compiled
404.htmlright in the manifest lets the edge answer invalid paths in milliseconds without waking the origin. - Keep scripts off the critical path: Fast TTFB is wasted if 300 KB of hydration JavaScript blocks first paint on a mid-range phone. Static HTML ships with zero framework hydration; lightweight behaviour scripts load deferred after first paint and only for behaviours actually attached to the page.
Continue reading
Have an architecture challenge to discuss?
Get in touch for staff-level architecture advisory or product collaboration.