What's a CDN and How Can It Help My Website?

Director of Development Operations
Published 2/6/14
Share This Post: 

Share This:

The term CDN, which stands for Content Delivery Network, is often thrown around as a solution to speed up your website, but the actual implementation is not always clear. Today we're going to take a look at the functions of a CDN and how using a CDN can benefit your website.

There are many CDN providers in the web space today including Akamai, CloudFlare and the provider we use at Miles, Level3. Choosing one is not obvious based on a quick Google search, but understanding how a CDN works can help make your decision easier.

A CDN will take your static content, like images, videos, javascript, and/or css files, and host them for you. From the point of view of the web developer, that means the URLs in your HTML source will link to the CDN provider, not your website.

For instance, instead of:

<img src="https://www.milespartnership.com/images/huge_picture_of_my_cat.jpg" /> or <img src="https://www.milespartnership.com/%3Ca%20href%3D"http://www.example.com/images/huge_picture_of_my_cat.jpg">http://www.example.com/images/huge_picture_of_my_cat.jpg" />

You would have:

<img src="https://www.milespartnership.com/%3Ca%20href%3D"http://cdn.example.com/images/huge_picture_of_my_cat.jpg">http://cdn.example.com/images/huge_picture_of_my_cat.jpg" />

How those static content files get on the CDN provider's servers varies, but with Level3 we configure an origin server in our account so that Level3 can automatically retrieve the static content from our origin server if it doesn't already have it on its edge servers.

A CDN provider's server is often called an edge server because they are physically located as close as possible to the web user's internet service provider, or on the edge of the ISP's network. Generally, a CDN provider will have edge servers in major metropolitan areas all over the world. When a browser requests content from the edge server, it gets the one closest to them through geographically based DNS.

By serving static content through a CDN, oftentimes large images and videos, you remove that task from your web server.

For example, a user in Chicago will get a different IP address when looking up cdn.example.com than a user in San Francisco. So that's all great, and it makes one a little dizzy when thinking too hard about it, but how does that improve a website?

  1. Serve up static content to your user faster: Edge servers are physically located closer to your website users, making their network roundtrip shorter than if they had to go all the way to your web server to download the static content you've placed on the CDN. They are also located in data centers with very fast network connections on servers specifically tuned to serve up that content as fast as possible.
  2. Take load off of your server: By serving static content through a CDN, oftentimes large images and videos, you remove that task from your web server and allow it more capacity to serve the dynamic content of your site.
  3. Improve load times on your site: With CDN-based images loading quickly from the CDN and your server not having to deal with serving that static content, your site's load time will improve for your end user.
  4. Save bandwidth: CDN bandwidth is often cheaper than the bandwidth you're paying for with your web host.