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

Posted by Ryan Ternier on ASP.net Weblogs See other posts from ASP.net Weblogs or by Ryan Ternier
Published on Mon, 14 Jun 2010 16:16:00 GMT Indexed on 2010/06/14 17:02 UTC
Read the original article Hit count: 658

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.

© ASP.net Weblogs or respective owner

Related posts about JavaScript

Related posts about General Software Developm