On this page
Kind: cross-cutting concept. Read this if you are an SRE or front-end engineer and need to know what the edge caches, what it never caches and how page speed is observed.
Up/Down: up: L2 Containers. Where the edge runs: Deployment.
In short#
How requests travel from Vietnam browsers to the distant origin, how compression and caching separate public assets from tenant data, and how dashboards stream initial panel data in one round-trip while field RUM tracks Core Web Vitals. Authoritative record: docs/adr/0064-edge-delivery-and-dashboard-streaming.md.
Why latency accumulates across continents#
A single HTTP request from Vietnam to a distant origin region pays ~215 ms of propagation delay even when the server computes in 10 ms. Four multipliers turn 215 ms into multi-second page loads:
| Multiplier | Mechanism | Mitigation in place |
|---|---|---|
| Handshake trips | Direct TCP + TLS 1.3 to the origin adds 2 RTT (~450 ms) on cold connections | Cloudflare proxy (orange-cloud) on the platform host, the tenant wildcard, the assets host terminates HTTP/3 QUIC + TLS at regional edge PoPs |
| Wire bloat | gzip HTML is ~53% larger than Brotli; re-compressing woff2 wastes CPU |
Traefik msocloud- orders encodings: [br, gzip] and excludes pre-compressed fonts, images, video, and text/ |
| Serial client trips | Rendering widget frames only after browser hydration + chunk import adds 2–3 extra 215 ms round-trips | Server-side active-tab panel prefetch (Hydration) + eager preload on mount and tab switch |
| Sequential DB hops | Serial SQL lookups in auth, layout, and page metadata add avoidable origin wait | Concurrent users + orgMemberships in auth, hoisted getLauncher inside the layout RLS scope, parallel page setup |
Proxy and caching boundaries#
Every route falls into one of four strict caching tiers so performance never compromises tenant isolation or strict CSP:
| Surface | Example paths | Set- |
Edge cache policy | Why |
|---|---|---|---|---|
| Hashed static assets | assets host/ |
Never | public, max- |
Content-addressed filenames; served from Cloudflare edge (HIT) |
| Unlocked public shares | GET / (signed-out, no password cookie) |
Never (public-) |
public, s- |
Explicitly permitted by apps/; zero cookies |
| Anonymous nonced HTML | /, /, /, /, / |
Never (public-) |
private, no- |
Root layout injects a per-request CSP nonce; caching nonced HTML at a shared CDN would replay one nonce across visitors |
| Authenticated tenant traffic | /, /, /, / |
Session / anchor as required | private, no- |
Tenant-scoped RLS data; never stored in shared caches |
apps/web/src/lib/public-proxy-bypass.ts keeps strictly anonymous public routes and /api/rum / /api/csp-report beacons out of NextAuth(edgeAuthConfig).auth(...). Any request carrying an Auth.js session cookie, the .platform host identity anchor, ADMIN_ORG_COOKIE, ?sso=, or landing on / of a tenant host still runs the full authenticated proxy path.
Single-trip dashboard delivery#
Key modules in this path:
apps/web/src/server/dashboard-prefetch-plan.ts— pure planner shared by runtime and unit tests (DASHBOARD_PREFETCH_CONCURRENCY = 6,DASHBOARD_PREFETCH_MAX_WIDGETS = 16).apps/web/src/server/dashboard-prefetch.ts— server-only runner usingcreateTRPCOptionsProxyandSuperJSON.serializeover the request's already-pinned tenantAppContext.apps/web/src/trpc/provider.tsx— pairshydrate: { deserializeData: SuperJSON.deserialize }with the existing 60-secondstaleTime.apps/web/src/app/(dashboard)/dashboards/[slug]/_components/dashboard-view.tsx— callspreloadWidgetFamilies(widgetFamiliesOf(...))for the active tab and on tab switches (selectTab) so widget family chunks load in parallel without waiting for individualFamilySlotmounts.
Observability and regional migration gate#
Performance decisions rely on live production telemetry rather than synthetic guesses:
| Signal | Source | Exposed as | Cardinality & privacy rule |
|---|---|---|---|
| Per-stage API latency | apps/ |
Server- |
Durations only; never emits tenant slugs or procedure inputs |
| Field Core Web Vitals | apps/ → POST / |
yng_, yng_, yng_, yng_ |
Paths collapse to 11 fixed templates; share tokens and slugs stripped |
| Browser bfcache rate | pageshow (event.) → POST / |
yng_ |
Zero unload listeners attached; lazily loaded during idle time |
Decisions and gates#
| Decision | Mechanism | Enforcing gate |
|---|---|---|
| Brotli-first origin compression and binary exclusions | infra/ |
apps/ |
| Cookie-free anonymous public proxy bypass | apps/, apps/ |
apps/, share- |
| Bounded active-tab server panel prefetch | apps/, dashboard- |
apps/, limits- |
| Eager widget family preloading under bundle budget | dashboard-, widget- |
pnpm run performance:budget, scripts/ |
Granular Server- and bounded-cardinality RUM |
apps/, apps/ |
apps/, scripts/ |
Where it stops#
Covered here: the active delivery path, compression policy, prefetch pipeline, and observability gates. Operator Cloudflare dashboard steps live in the internal tenant domains runbook; numeric ceilings are pinned in Limits and budgets.