Friday, May 17, 2013

Specify a CDN fallback when using ASP.NET Web Optimizations

One of the recommendations to improve your web application performance is to use a CDN(Content Delivery Network). This allows you to load common files(like for example jQuery) from the CDN server instead of your own. Extra advantage is that if the user already loaded the same script for another site, it’s still available in the browser cache.

But what if the CDN you’re using goes down? To fix this you can use a CDN fallback. For more details I recommend reading Scott Hanselmans post on the subject.

The ASP.NET team added a CDN fallback feature to the latest (prerelease) version of the ASP.NET Web Optimizations library. To use it, specify a CdnFallBackExpression.  This expression will be checked and if the expression fails, the fallback URL will be used(a local reference to jQuery in this sample):

No comments: