Posts Tagged ‘ASP.NET AJAX’

Who hosts your Ajax script files?

September 18, 2009 Leave a comment

Already Google is hosting the script files for lot of AJAX frameworks like jQuery, Dojo etc. It is a sure thing that using the script files hosted in CDN makes sense rather than using script files hosted in our own servers.

In case if some one wonders what CDN is: CDN stands Content Delivery Network. The static content (like java script files or libraries) of our application will be distributed in various physical locations. When the browser resolves the URL for this static content, the download will happen from the closest available server in the network.

Using a CDN can significantly improve a website’s end-user performance, since it enables browsers to more quickly retrieve and download content. For example, instead of having a browser request for an image traverse all the way across the Internet to your web server to download, a CDN can instead serve the request directly from a nearby “edge cache” server that might only be a single network hop away from your customer (making it return much faster – which makes your pages load quicker).

Now Microsoft has launched new Ajax CDN service that provides caching support for AJAX libraries. This includes both jQuery and ASP.NET AJAX. This service is available for free (for both personal and commercial purpose) and does not need any registration. (via Scott Gu).

With CDN we could simply use
<script src="” type=”text/javascript”>
<script src="” type=”text/javascript”>

The above setting is OK for the explicit java script library reference. But what about some implicit java script libraries like ASP.NET AJAX and for the java script files used by web forms (like WebUIValidation etc)?

There is a new tag introduced in ASP.NET 4.0 for ScriptManger: EnableCdn = "true". Using this tag will force the application to retrieve the java script files from System.Web.dll or System.Web.Extensions.dll hosted in CDN instead of retrieving them from our server.

This improves performance as the user accessing our ASP.NET website won’t need to re-download these files if they have already visited another ASP.NET website that uses CDN.

Other than known benefits like the request will be processed much faster, the interesting thing comes here:

You don’t have to pay for the bandwidth of this file – since the file comes from Microsoft server Microsoft pays the bandwidth cost and thus saving our money.

Now the only problem left over with this implementation is Trust. How will the corporate banks trust their users to freely download the java script file that is hosted in a different server? The fact that it is hosted by Microsoft may not be enough to increase the trust level. And another problem may be Fail over impact. But this can be easily handled in the code.

In any case this looks promising for a public web site that has users located in various physical locations. Any way we will have to thank Google to provide this CDN for java script libraries at first.

Full listing of java script libraries loaded in Microsoft CDN is here:

The following releases of Microsoft Ajax are hosted on the CDN:

Microsoft Ajax version 0909 (preview)

The following releases of jQuery are hosted on the CDN:

jQuery version 1.3.2

Full listing of java script libraries loaded in Google CDN is here:

Google hosts an array of script libraries like jQuery, Dojo, MooTools including jQuey UI. Clearly it targets wide array of developers. (And un like other Google services, Google Code is not Beta!)

Categories: AJAX, ASP.NET Tags: , ,