What is CDN? How does it Work?

What is CDN? How does it Work?

Picture Source : https://www.cloudflare.com/learning/cdn/what-is-a-cdn/

A content delivery network (CDN) is a system of distributed servers (network) that deliver pages and other Web content to a user, based on the geographic locations of the user, the origin of the web-page and the content delivery server.

CDN, or in other words a Content Delivery Network, is “a network of geographically distributed servers which caches the static content (CSS, Javascript, Images and other static components) of a website or blog” according to Wikipedia. In laymen’s terms: a CDN speeds up the time it takes for your website to load when visitors click on your page.

Here’s how it works:

To explain how the system works, imagine you have a website (yourname.com) and it's running an a server with the following IP address (

Before CDN, if someone typed your website's domain (yourname.com) into their browser, or clicked on a link that pointed to your website, the first thing that visitor's computer would do is a query to the DNS system and get back your web server's IP address (

In order to make CDN easy to setup, CDN providers take advantage of how this basic function of the Internet works. Rather than having you add hardware, install software, or change your code, instead they have you designate their name servers as the authoritative for your domain (e.g., bob.ns.cloudflare.com / sara.ns.cloudflare.com). You make this change with the registrar from which you bought your domain (e.g., GoDaddy, Network Solutions, Register.com, etc.).

Note that designating CDN as your authoritative name servers doesn't change anything else about your website's ecosystem. Your registrar remains your registrar. Your hosting provider remains your hosting provider. However, because CDN server are your authoritative name server, they can begin cleaning and accelerating your traffic.

To make this happen CDN providers use a network routing technology called Anycast, and some other fancy tricks, to route initial DNS lookups for your domain (yourdomain.com) to the data center nearest the visitor.

The CDN data center that receives the request returns an answer, in the form of an IP address (, which directs the visitor's subsequent requests to the best data center for them.

After a visitor's browser has done the initial DNS lookup, it begins making requests to retrieve the actual content of a website. These requests are directed to the IP address that was returned from the DNS lookup. Before CDN technology, that would have been, with CDN technology as the authoritative name server that would be (or some other address depending on what CDN data center is closest to the user). CDN's frontline servers running on that IP address receive the request and perform analysis on it

CDN caches parts of websites that are static. For example, CDN cache things like images, CSS, and Javascript. CDN are very conservative with our caching because we never want to mess up dynamic content. So, for example, as a general rule we do not cache HTML. CDN also refresh the cache relatively frequently, so files are never more than a few hours old. Even being conservative, however, typically 50% of the resources on any given web page are cachable. What's terrific about that is it means if CDN datacenter have a local copy of your file then it can deliver it directly to the visitor from a local data center and the speed is extremely fast.

If the request is for a type of resource CDN don't cache, or if we don't have a current copy in its cache, then it make a request from it’s data center ( back to your origin server ( Because its relatively high scale, it can get premium routes from its data centers back to most places on the Internet. As a result, while it may seem counter-intuitive, it is sometimes the case that the number of "hops" a visitor request makes going through the CDN network is less than the number of "hops" that they would have made going to the origin webserver directly, even when its not able to return a result from its cache.

The combination of these systems means that CDN can protect sites from malicious visitors by stopping them before they even get to the origin web server, save over 60% of the bandwidth that a site would otherwise have to pay for, save over 65% of the requests that would otherwise have to be handled by a site, and cut in half average page load times. In order to make performance even better, it also do some web content optimization.

Here’s another major advantage of CDN: it’s cheaper! The decreased expense is because CDN saves on bandwidth, rack space, power, and cooling Since the CDN provides the configuration and hardware, you save money and the headache of maintaining that infrastructure. 

A simple Internet search will reveal CDNs that you can use with your website regardless of its degree of complexity. Finding a suitable CDN solution does not need to be a complicated process. But it is a recommended process if you are looking to improve your site’s overall functionality.

Happy to provide more detail on any of the above if you still have questions, then freely to ask.

Except where otherwise noted, content on this site is licensed under a CC BY-NC-SA 4.0 .