Why we need a CDN for global users?
Content Delivery Networks explained through edge caching, cache headers, versioned assets, invalidation, origin protection and the limits of caching personalised data.
Why we need a CDN for global users?
A user in Asia is not becoming closer to an origin server because the application is deployed in Azure. The request is still travelling across networks, and repeated JavaScript, styles and images are still travelling the same long distance. In the previous article, we discussed network security, Key Vault and least privilege. In this article, we are going to see why a Content Delivery Network (CDN) is useful for global users, what it can accelerate and what it must never cache.
TL;DR Summary
- A CDN caches eligible content at edge locations closer to users.
- A cache hit avoids a trip to the origin, while a cache miss still reaches the origin.
- Azure CDN can use providers such as Verizon or Akamai, depending on the selected offering.
- Cache headers, cache keys, expiry and invalidation are part of the application design.
- Static assets are normally safer to cache than personalised fund data.
- A CDN will not fix a slow SQL query or a slow origin API.
- Measure origin requests, hit ratio and user latency after enabling it.
Challenges
Every request is reaching one origin
Without an edge cache, users in Asia, the US and Europe are all reaching the same North Europe Web App. Static JavaScript, CSS and images are downloaded repeatedly from the origin. Distance is adding latency and the origin is doing work which could have been served closer to the user.
The wrong response is cached
A fund price or personalised document can be stale or confidential. If the cache key and response headers are not designed, a CDN can serve one user’s content to another user or return an old business value. Performance is never a reason to weaken correctness.
Invalidation becomes a release concern
A new JavaScript bundle must become visible after deployment. A team which has not planned invalidation will see an old bundle and may blame the Web App. Versioned filenames and an explicit invalidation process are reducing this confusion.
What is a CDN?
A Content Delivery Network is a distributed network of edge servers which caches and serves eligible content closer to requesting users.
In simple terms, the CDN is keeping a copy of safe, reusable content near the audience, so the origin is contacted only when the edge does not have a valid copy. It is not replacing the Web App or database.
An everyday analogy is a chain of local warehouses. A central factory is producing the product, while local warehouses keep popular products near customers. The warehouses are useful for repeated products, but they must not be shipping a private order to the wrong customer.
Why a CDN is important?
A CDN is important when users are global and the application has cacheable assets or public responses. It can reduce latency and origin load, but it adds another layer where headers, certificates, purge behaviour and access controls must be understood.
The following diagram depicts the same users with and without a CDN:

Without the CDN, users in Asia, the US and Europe are reaching one North Europe origin. With the CDN, each group is reaching a nearby edge, and only a cache miss is travelling to the origin. The orange edge boxes represent a CDN vendor boundary such as Verizon or Akamai, while the Azure Web App remains our component.
Cache headers and keys
The origin is controlling caching through HTTP headers. A versioned static asset can be cached for a long time:
HTTP/1.1 200 OK
Cache-Control: public, max-age=31536000
ETag: "fund-spa-v42"
Content-Type: application/javascript
When the JavaScript filename is changing from app.js to app.v43.js, old clients can finish using the old asset and new clients can receive the new one. This is safer than trying to purge every edge at exactly the same moment.
A response containing a customer-specific document should normally be marked private:
Cache-Control: private, no-store
Vary: Authorization
The exact policy depends on authentication and content. Vary is not a magic security boundary, so the CDN configuration and origin behaviour must be reviewed together. A cache key should include the query parameters which change the result, otherwise fundId=123 and fundId=456 can be treated as the same object.
What should be cached?
| Content | Typical policy | Reason |
|---|---|---|
| SPA JavaScript and CSS | Long expiry with versioned names | Safe and reusable |
| Public fund images | Long expiry with purge or versioning | Repeated static content |
| Public news articles | Short expiry or explicit invalidation | Changes less often but can be updated |
| Current unit price | Short policy only if business accepts staleness | Financial value changes |
| Personal documents | Private or no-store | User-specific data |
| POST, payment and order responses | Do not cache | Side effects and confidentiality |
The CDN is not making a transaction safe. A POST creating a unit purchase must reach the API with its authentication and idempotency rules. A CDN can be placed in front of safe GET responses only when the response contract is understood.
Origin protection and measurement
The CDN can reduce static requests, but the origin is still handling cache misses and dynamic APIs. We should monitor the origin request rate, cache hit ratio, edge response latency, 4xx/5xx responses and purge failures. A high hit ratio with an incorrect cache policy is a security defect, not a success.
In our case, the fund SPA uses versioned assets, public news images are cached, and the current fund price remains dynamic until the business accepts a defined stale window. The origin is still protected with authentication and NSGs. We will discuss the API Gateway and the policies which apply to dynamic API traffic in an upcoming article.
A safe release with a CDN
The release publishes app.v43.js before the HTML points to it. During a short transition, both app.v42.js and app.v43.js are available at the edge. After the new HTML serves correctly, the old asset can expire naturally. This avoids a release which depends on a global purge completing at one exact moment.
When a public news article is corrected, the team chooses between a short cache lifetime and an explicit purge. A correction to a private factsheet is not solved by making the CDN cache shorter; the response is marked private and the access path is checked. A cache header is therefore part of the content contract.
The origin is setting an ETag so an edge or browser can make a conditional request. A 304 response is reducing the payload, but it is not the same as a cache hit at a distant origin. The measurement is separating browser cache, CDN cache and origin response time. Otherwise a reported performance improvement can be coming from the wrong layer.
Azure CDN offerings can use Verizon or Akamai providers. The provider boundary is documented with certificates, purge permissions, support contacts and logs. The choice is not only about the nearest edge; it is also about who responds when cached content is wrong.
The support process checks a cache miss and a cache hit separately. A response header shows which layer served the content, and a purge request records the asset version. This prevents the team from guessing whether an old factsheet comes from a browser, the CDN edge or the origin.
Trade-offs
| Approach | Pros | Cons |
|---|---|---|
| Origin only | + Simple routing and invalidation<br>+ One place to reason about data | − Global users see more latency<br>− Origin serves repeated static requests |
| CDN for selected content | + Lower latency and origin load<br>+ Good fit for static assets | − Cache policy and invalidation are required<br>− Adds an operational boundary |
| CDN for all responses | + Potentially high hit ratio | − High risk for private or changing data<br>− Correctness is difficult to prove |
Must Do and Don’ts
- Must Do: Use versioned names for deployed assets, otherwise old and new JavaScript can be mixed after a release.
- Must Do: Set cache headers from the origin and review the query-string cache key, because the edge needs to know what changes a response.
- Must Do: Keep private documents and side-effecting requests out of the cache, otherwise users can see another user’s data or repeat a write.
- Must Do: Measure hit ratio and origin traffic, so the CDN decision is validated against the user experience.
- Don’t: cache the current fund price blindly, because stale financial data can be worse than slower data.
- Don’t: assume a CDN fixes a slow SQL query, because dynamic cache misses are still reaching the origin.
Wrap up
In this article, we have looked at edge locations, Azure CDN providers, cache headers, versioned assets, cache keys and safe content categories. A CDN is useful when it protects the right content and preserves correctness. I really appreciate that you took the time to read this article, and I hope this article provided you some insights into global delivery. This is the final Cloud Solution Architecture article for 2016; in the next article, I will walk you through Microservices - Part 1.
Related Posts
How to use Azure Redis Cache for session state and output cache?
Azure Redis Cache explained for shared session state and output caching, including providers, configuration, cache-aside usage, and multiple web instances.
Azure Service Fabric vs Azure Container Service vs App Service - choosing a hosting model
Azure Service Fabric, Azure Container Service, App Service and Virtual Machines compared through workload fit, operational ownership, scaling and deployment responsibilities.
Designing a multi-region application on Azure - traffic manager and failover
Multi-region Azure application design explained through Traffic Manager routing, primary and secondary regions, SQL replication, latency, health checks and failover practice.