How to Use Content Delivery Networks

Microsoft, Google and Amazon are three of the biggest companies in the world, not to mention standard bearers in the tech industry. So, it goes without saying that their names each carry significant weight and ensure a certain level of (high) quality.

When it comes to selecting a content delivery network (CDN), many Web professionals want to be associated with well-known, dependable companies. Luckily for them, Microsoft and Amazon both offer their own CDN solutions (Windows Azure and CloudFront, respectively), but if they want a cheaper and easier method that still comes attached to a major tech name, Google's App Engine can also be turned into a CDN.

If you're interested and want information on how to set up a Windows Azure CDN, Amazon CloudFront or Google App Engine CDN, keep reading.

Windows Azure
Getting started with a Windows Azure CDN boils down to three steps:

1. Create a storage account or hosted service
2. Enable the CDN with your content provider
3. Access your CDN content

Creating a storage account is pretty simple. You start by logging into the Windows Azure Management Portal, and then click on the "New" tab in the lower left-hand corner and selecting the "Storage" option. From here, you want to click on "Quick Create," which will pull up the Create Storage Account dialogue box.

In this box, you need to insert a subdomain name (which can contain anywhere from 3-24 lowercase letters and number) into the URL field. This will be the host name within the uniform resource identifier (URI) that addresses Blob, Queue or Table resources for the subscription, as well as the name of the storage account in the portal. Because of this, you must select a name that is completely unique among all of the Windows Azure hosted services.

Next, in the "Region/Affinity" group section, select a geographic location or select an affinity group for your account from the drop-down list. Then, on the "Subscription" drop-down list, select the subscription type that you want to use with your account.

After that, just click on "Create Storage Account," and after a few minutes, you'll just have to verify that your account was created successfully by looking in the items listed for "Storage" with a status that reads, "Online."

To enable your CDN, return to the Management Portal, click "Preview," and the choose "Take me to the preview portal." From here, click "Hosted Services, Storage Accounts & CDN," which will open up a new navigation pane. Click on "CDN" and then select "New Endpoint" on the ribbon. This should prompt a the Create a New CDN Endpoint dialogue box.

Under "Choose a subscription," select the subscription you want to enable your CDN on from the drop-down menu. Then, you can select the source of your new CDN's content and determine the origin (that is, the single location your CDN will use to get content to put in the cache network) of your CDN account from the "Choose a hosted service or storage account" drop-down list. The source URL for the CDN Endpoint should automatically display the URL for the origin.

Naturally, you'll want to make sure the "Enable CDN" box is checked, but if you need to use HTTPS connections, check the "HTTPS" box. Likewise, if you're caching content from a hosted service and using query strings to point out which content will be retrieved, check the "Query String" box; do not click on this if you're using a blob storage account.

After that, just click OK and you're done! You can then access the content on your new Windows Azure CDN by going to: https:// .vo.msecnd.net/ / (with your unique information entered the appropriate places, of course.

Amazon CloudFront
To combine your Amazon S3 account with CloudFront to use as a CDN (assuming you have one already), start by signing up for the CloudFront service and ensuring that it's activated for you. Then, download an application for managing your S3 buckets that also features CloudFront support, such as S3 Firefox (an add-on for the Firefox Web browser).

In order to connect your Amazon account with S3 Firefox, right click on a bucket name and choose the "Manage Distributions" option so you can establish a new distribution (a URL used to reference a file). Do this by clicking on "Create Distribution." This will create a new domain name that looks like: .cloudfront.net . Just wait for your status to turn from "InProgress" to "Deployed."

Once your distribution is up-and-running, you'll probably want to create a CNAME, because the there isn't really any way to customize what goes before ".cloudfront.net" in your distribution URL. The CNAME will make it simpler and easier to remember and map it wherever you want. You can do this by going through your Web hosting provider and then filling up the CNAME section in S3 Firefox.

Google App Engine
Turning the Google App Engine into a makeshift CDN is a considerably easier (and cheaper) route to take, while still providing the quality that Google is know for.

Simply start by siging up for the Google App Engine and creating an app for your site. Then download the App Engine software development kit (SDK) and create another new application on your development machine.

Next, you'll have to create some image, CSS and JavaScript directories. Select the app.yaml configuration file and create handles for all of those directories. Also, if you plan on using far-future expiration for more long-term browser caching, you're going to need to add the normally optional "default_expiration" tag.

Finally, copy all of your static content and put it in the directories you created and deploy the app. Then change all of the static content references on your site to point to https:// .appspot.com .

Now, if you want to add a custom domain, you'll need to start by setting up Google Apps for your domain. Once that's done, log into your hosting environment and place a "static" subdomain CNAME that points to ghts.google.com.

Then, return to the App Engine dashboard and click on "Application Settings." Under the "Domain Setup" tab, click on "Add Domain" and type in the name of your domain; click on the "Add" button to redirect yourself to your Google Apps domain and accept the terms and conditions.

After that, go to Settings and click on "Add New URL" and enter the CNAME subdomain you previous set up. Go ahead and change all of the static content references on your site to point to your subdomain and voilà! Great job!