CDN for Node.js

Serve versioned public files through Cloud CDN. Leave writes, private API responses and requests that depend on an active session with your Node.js service.

Example cache policy
Public, cacheable resource
/public/app.73fa.js
Bypass shared cache
/api/me

Separate static delivery from application routes

Put Cloud CDN in front of the Node origin. Cache static middleware output and public GET JSON. Bypass authenticated APIs and POST.

Static middleware at the edge

The edge can reuse public files that the Node.js origin marks as cacheable.

Public GET JSON from cache

Identical API GETs can be stored at the edge with a TTL you choose.

Origin Shield for Node

Miss storms are consolidated before they hit a small Node cluster.

Configuration

Cloud CDN overview
  1. Front the Node listen port with Cloud CDN

    Pull HTTPS from a reverse proxy in front of Node, or TLS at the origin.

  2. Cache static routes first

    Start with /public, /assets and hashed front-end files.

  3. Add cacheable API GETs

    Only responses that are identical for every anonymous client.

  4. Bypass the rest

    WebSockets, POST, and authenticated JSON stay on Node. See CDN for WebSockets.

Operational outcomes

  • Node static files are cached globally
  • Public GET APIs can be cached
  • Authenticated APIs remain dynamic
  • Origin Shield protects small clusters

Frequently asked questions

Does this work with Express, Fastify and Koa?

Yes. Cloud CDN fronts the HTTP origin, independent of the Node framework.

Can I cache SSR from a Node server?

Cache anonymous HTML. Bypass render output that varies on cookies. See Next.js, Nuxt and Remix pages.

How should I handle ETags?

Cloud CDN can reuse origin validators. Prefer explicit TTLs plus purge for HTML.

Are WebSockets supported?

Cloud CDN supports WebSockets for dynamic paths that bypass cache. See the WebSockets page.