CDN vs reverse proxy: what each layer is for

A reverse proxy sits in one place. A CDN is a global cache and TLS edge. When to use nginx or an application proxy, and when to use Cloud CDN.

nginx, Caddy, HAProxy and cloud load balancers are reverse proxies. They terminate TLS, route paths and sometimes cache — in one region. A CDN does related work at 210+ locations, with purge, Anycast and origin protection as the product.

Same verbs, different geography

Both can cache GET, strip headers and proxy to an upstream. The proxy usually sits next to the app. The CDN sits next to the user.

If all of your users are in one metro, a local proxy may be enough. The moment they are not, the proxy becomes the origin as far as the world is concerned.

What you should keep on the proxy

Application routing, WebSocket upgrades to a specific worker, internal auth, and caching that depends on application internals can stay on nginx or the framework.

Cloud CDN does not replace your app router. It reduces how often that router runs for public GETs.

What you should move to the CDN

Public TLS, global cache, image transformation, large-file delivery, DDoS absorption and hiding the origin IP belong at the edge.

You can still run nginx behind Cloud CDN. Many teams do. The proxy then sees Shield-consolidated misses instead of the whole internet.

Do not double-cache blindly

A stale proxy cache behind a stale CDN cache is two clocks to debug. Pick TTLs per layer. Purge both on deploy if both store HTML.

Hashed assets can be cached in both places. HTML should have a single operator who is allowed to invalidate it.

Frequently Asked Questions

It can replace nginx as the public edge. It does not replace application-specific proxy rules you still want next to the origin.

No. A load balancer spreads connections across origin instances in a region. A CDN caches across regions.

They can share the hostname. Cloud CDN supports WebSockets and will not cache the socket. Static assets on the same host still benefit.

Put this on Cloud CDN.

Get started with our Management Console in less than 2 minutes, or connect with an expert to supercharge your business today.