CDN for React

Deliver the React build from a static or application origin. Keep the entry document fresh as releases introduce new versioned JavaScript and stylesheet URLs.

Example release policy
Versioned resource
/assets/index.a991.js
Refresh on publication
/index.html

Set separate lifetimes for HTML and bundles

Cache hashed bundles at Cloud CDN with long TTLs. Serve index.html with purge on deploy. Keep BFF and API routes dynamic.

Versioned JavaScript bundles

Visitors can reuse cached JavaScript, stylesheets and fonts when a release keeps the same URLs.

Control caching for index.html

Purge the shell on release so clients pick up the new hashed filenames.

Static media beside the app

Public images and downloads use the same distribution.

Configuration

Cloud CDN overview
  1. Upload or host the React build

    Any HTTPS origin that serves the production build is enough.

  2. Long-cache hashed assets

    Fingerprinted files can live at the edge until the filename changes.

  3. Purge the HTML shell on deploy

    Invalidate index.html and any unhashed paths in CI.

  4. Attach the app hostname

    Enable TLS and point DNS at the distribution.

Operational outcomes

  • React bundles are delivered globally
  • Deploys purge the HTML shell
  • APIs stay on the origin
  • Images and fonts share the same edge

Frequently asked questions

Does this work with Vite or CRA builds?

Yes. Cloud CDN cares about the files, not the bundler.

Can I cache a React SSR app?

Cache anonymous HTML. Bypass session-specific render output. See also CDN for Next.js and Remix.

How do I handle client-side routing?

Configure origin fallback to index.html for app routes, then cache that HTML carefully.

Should API calls go through the CDN?

Static GETs can. Authenticated APIs should bypass cache or use a separate hostname.