Last Tuesday, Scott Guthrie announced in his blog the new Microsoft AJAX content delivery network (CDN), this is great news to all of us using AJAX in our commercial and non-commercial applications.
What is it?
First of all, a CDN is a Content Delivery Network which is composed of multiple servers strategically placed across the globe. In the case of the Microsoft AJAX CDN servers, the jQuery and ASP.NET AJAX libraries are cached across multiple web-sites around the world and they are available to you now. If your website loads these AJAX libraries from the Microsoft AJAX CDN servers, your AJAX enabled pages will load faster than when loaded from your own server.
What are the benefits?
Think about it, right now you might have several websites (or one) that utilizes the jQuery or ASP.NET AJAX libraries, every time a user opens your AJAX enabled page, this library or libraries need to be loaded from your own server. In some cases depending on where the website user is located geographically, these files will have to travel through the wire from a few hundred miles to thousands of miles (if you have people from across the pond looking at your website) making your page slower to load. The new Microsoft AJAX CDN will help you improve the performance of your website by serving the requests for these files directly from a nearby “edge cache” server.
Also, these files can be cached across multiple websites, meaning that users accessing your website won’t need to re-download these files if they have visited another ASP.NET AJAX enabled website that uses the CDN, and you know that speed is king when loading websites.
How do you use it?
One of the main benefits I see with this (other than my web pages loading quicker) is that you can implement this to new and existing AJAX enabled websites very easily. Below is an example on how to use jQuery from the Microsoft AJAX CDN, you just need to add a script tag to your page using the URL below:
When your page opens, the browser will request the script file from one of the closest CDN servers to the end-user loading your page quicker and saving bandwidth since the Microsoft AJAX CDN server pays the bandwidth cost.
Also, in ASP.NET 4.0 the ScriptManager includes a new property (EnableCdn). If you want to use the Microsoft AJAX CDN all you have to do is set this property to “true”, see example below:
By setting the EnableCdn property to true, your application will retrieve all the JavaScript files from the CDN instead of downloading them from your server, which in many cases will probably take longer and you are also paying for the bandwidth, and remember that this service is free of charge, for commercial and non-commercial applications, sounds like a good idea to me :).
How do you use the ASP.NET AJAX Preview 5 with CDN?
It looks like the AJAX team at Microsoft has been busy this month, in addition to the Microsoft AJAX CDN, the team also released the ASP.NET AJAX Preview 5 a few days ago. This is available in CodePlex now.
Or, you can also use the CDN to load files from ASP.NET AJAX Preview 5 by using the following scripts:
Note the directories in the URL “beta/0909” which specifies that you are requesting the files from the beta version released on 9/2009 – ASP.NET AJAX Preview 5.
I believe this is a great solution and there is no reason not to start using it now, of course I recommend you do all the testing required to make sure everything works the way you like. I have been using jQuery a lot more than the ASP.NET AJAX libraries lately, I am so interested in this jQuery library because of all the power it has in such a compact package, and the fact that Microsoft is supporting it is yet another reason for me to continue using it. I already started changing some of my scripts to use the CDN and will be doing some testing to see how much faster my pages load – I am sure any speed gain will be enough reason for me to use it.
No comments:
Post a Comment