Java Script – Content delivery networks (CDN) can bite you in the butt.

As much as I love the new CDN’s that Google, Microsoft and a few others have publically released, there are some strong gotchas that could come up and bite you in the ass if you’re not careful. But before we jump into that, for those that are not 100% sure what a CDN is (besides Canadian).

 

Content Delivery Network.

A way of distributing your static content across various servers in different physical locations.  Because this static content is stored on many servers around the world, whenever a user needs to access this content, they are given the closest server to their location for this data.

Already you can probably see the immediate bonuses to a system like this:

  1. Lower bandwidth
    1. Even small script files downloaded thousands of times will start to take a noticeable hit on your bandwidth meter.
  2. Less connections/hits to your web server which gives better latency
  3. If you manage many servers, you don’t need to manually update each server with scripts.
  4. A user will download a script for each website they visit. If a user is redirected to many domains/sub-domains within your web site, they might download many copies of the same file. When a system sees multiple requests from the same  domain, they will ignore the download

 

Those are just a handful of the many bonuses a CDN will give you. And for the average website, a CDN is great choice. Check out the following CDN links for their solutions:

The Gotcha

There is always a catch. Here are some issues I found with using CDN’s that hopefully can help you make your decision.

HTTP / HTTPS

If you are running a website behind SSL, make sure that when you reference your CDN data that you use https:// vs. http://. If you forget this users will get a very nice message telling them that their secure connection is trying to access unsecure data. For a developer this is fairly simple, but general users will get a bit anxious when seeing this.

Trusted Sites

Internet Explorer has this really nifty feature that allows users to specify what sites they trust, and by some defaults IE7 only allows trusted sites to be viewed.  No problem, they set your website as trusted. But what about your CDN? If a user sets your websites to trusted, but not the CDN, they will not download those static files. This has the potential to totally break your web site.

Pedantic Network Admins

This alone is sometimes the killer of projects. However, always be careful when you are going to use a CDN for a professional project. If a network / security admin sees that you’re referencing an outside source, or that a call from a website might hit an outside domain.. panties will be bunched, emails will be spewed out and well, no one wants that.

1 Comment

  • Hey Ryan,

    You should check out this tip that Jon Galloway wrote about last year. Using protocol relative hyperlinks. That will take care of the first concern you list. The others are out of the developers hands really.

Comments have been disabled for this content.