Skip to content

perf(web): reduce Cloudflare request bursts, cache assets, and respect rate limits - #21

Merged
LikC1606 merged 1 commit into
mainfrom
perf/cloudflare-request-optimization-20261125
Nov 25, 2026
Merged

LikC1606 merged 1 commit into
mainfrom
perf/cloudflare-request-optimization-20261125

Conversation

@LikC1606

Copy link
Copy Markdown
Collaborator

Summary

  • Cut ESM chunk fanout (scripts/build-web.ts): bundle each of the 8 online web entrypoints separately with splitting: true so dynamic imports (English dictionary, runViews) remain lazy without splitting shared modules into 20+ extra HTTP requests per cold page load (first visit drops from 34 to 17 static requests; research.js drops from 20 chunks to 1 shared chunk).
  • Edge & browser asset caching (apps/web/staticFiles.ts): serve immutable assets/katex/* with public, max-age=31536000, immutable, no-transform and assets/* (fonts, mark.svg, licenses) with public, max-age=86400, stale-while-revalidate=604800, no-transform, eliminating 7 repeat-visit origin/edge revalidations per page load.
  • SSE & polling pressure + 429 cooldowns: add retry: 5000 to /api/runs/stream (apps/web/server.ts), widen fallback polling intervals when SSE is disconnected (apps/web/client/app.ts), pause background polling when document.hidden is true and honor Retry-After / Cloudflare 1015 / cf-mitigated: challenge cooldowns in apps/web/client/researchShared.tsx, and reduce idle polling in researchViews.tsx, researchOverview.tsx, and collaborationMessageSummary.tsx.

Verification

  • bun run typecheck, bun run typecheck:web, bun run typecheck:site
  • Vitest (webResearchSession, webStaticFiles, webRunStream, webServer, webClient, webI18n, webFonts — 114 tests; plus test:frontend-research-unit)
  • Playwright (test:web-load, test:web-live-sync, test:web-rate-limit, test:web-research-workspace, test:web-ui, test:web-login, test:web-share, test:web-natural-first, test:web-performance, etc.)

@LikC1606
LikC1606 merged commit 39ae740 into main Nov 25, 2026
@LikC1606
LikC1606 deleted the perf/cloudflare-request-optimization-20261125 branch November 25, 2026 05:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant