An nginx cache near the application and a distributed CDN solve overlapping but different delivery problems.

Keep nginx next to the app

Routing, internal auth, and application-specific headers can stay on nginx. Cloud CDN sits in front and reduces how often nginx runs for public GETs.

The delivery model

How it works

CDN vs nginx

  1. 01nginxKeep application-specific proxy control near origin.
  2. 02CDNAdd distributed delivery and provider-managed operations.
  3. 03TogetherAssign clear cache and invalidation ownership.
Conceptual model for this configuration. The actual path depends on provider policy and application behavior.

What nginx will not give you

Distributed delivery adds regional infrastructure, routing, capacity planning, TLS operations, and observability. Compare the provider service with the infrastructure and ongoing staffing you would otherwise operate.

Double cache needs a boss

If nginx and Cloud CDN both store HTML, pick who purges. Hashed assets can live in both. HTML should have one invalidation owner.

WebSockets and apps

nginx can terminate sockets. Cloud CDN can pass them through on the same public hostname so you do not split cookies and CORS across hosts.

Validate before production

Compare total operating work, including capacity, TLS, logging, patching, regional reach, and incidents. If both layers cache, test freshness after an origin update and after each layer is invalidated independently.

  • Record the configuration and expected result before changing traffic.
  • Keep evidence of the test and a working rollback for the previous behavior.

Sources & further reading