Web / NGINX Interview questions
When should you use NGINX caching instead of a dedicated CDN?
NGINX caching and a CDN solve overlapping but distinct problems, and the right choice depends on where your traffic and latency concerns actually are.
NGINX's proxy_cache is a good fit when traffic is concentrated in one region close to your origin server, when cached content changes frequently enough that a CDN's longer propagation and purge cycles would be awkward, or when you want fine-grained, backend-aware cache logic without managing a third-party service.
A CDN wins when clients are geographically spread out - it caches content at edge locations physically close to users, cutting network latency in a way a single NGINX instance in one datacenter can't. CDNs also absorb traffic spikes and DDoS-style load before it ever reaches your origin at all.
Many production setups actually layer both: a CDN in front for global edge caching and traffic absorption, with NGINX's own caching behind it as a second layer protecting the origin from whatever traffic does get through.
More Related questions...