Telerik Extensions for ASP.NET MVC

One of the new features of Telerik Extensions for ASP.NET MVC is the ability to load web assets from the Telerik CDN (Content Delivery Network). The Telerik CDN is hosted on the Amazon CloudFront service, which is a global content delivery network with edge locations in the US, Europe and Asia.

Using the Content Delivery Network has a number of advantages:

  • Reduced Latency - requests will be automatically redirected to the nearest server.
  • Optimized Caching - assets will be downloaded only once, no matter from how many locations you are referring the same asset.
  • Compressed output - the assets are already compressed so their size will be minimal.
  • Reduced hosting expenses - we host the assets for you, so you can pay less.

When CDN support is enabled, all the Telerik web assets (JavaScript, CSS and image files) are served from the Telerik CDN.

Enabling CDN Globally

You can enable CDN support globally from a configuration file (web.config) or with code. To enable from a configuration file, set the useTelerikContentDeliveryNetwork attribute to true like this:

<telerik useTelerikContentDeliveryNetwork="true">

Alternatively, you can use the WebAssetDefaultSettings class. For example, the following code in global.asax will turn on CDN support for all web asset groups.

protected void Application_Start()
  WebAssetDefaultSettings.UseTelerikContentDeliveryNetwork = true;

Enabling CDN per Asset Group

You can enable CDN support per asset group for both ScriptRegistrar and StyleSheetRegistrar. Use the UseTelerikContentDeliveryNetwork method. The following example shows how to enable CDN for the default group of the ScriptRegistrar:

<%= Html.Telerik()
        .DefaultGroup(group => group.UseTelerikContentDeliveryNetwork(true))

Frequently Asked Questions

Question: What is the location of the Telerik CDN?
Answer: The web assets are served from the following locations:
  • CSS and image files:|mvcz/assemblyVersion
  • JavaScript files:|mvcz/assemblyVersion

The mvc or mvcz part depends on whether the browser supports gzip compression. mvcz is used for browsers which support compression, and mvc otherwise.

To avoid a known issue with Internet Explorer 6 and gzipped content, the CDN always serves uncompressed content to IE6 users.
Question: What about SSL?
Answer: When SSL is used, Telerik Extensions for ASP.NET MVC will use the native CloudFront distribution hosts:
  • CSS and image files:|mvcz/assemblyVersion
  • JavaScript files:|mvcz/assemblyVersion
You don't have to do anything special as both the ScriptRegistrar and the StyleSheetRegistrar automatically detect SSL requests and render the appropriate URLs.
Question: What is the difference between UseTelerikContentDeliveryNetwork and ContentDeliveryNetworkUrl?
Answer: Use the ContentDeliveryNetworkUrl if you want to load the assets of a group from your own CDN. For example, if you have a CDN you can use the ContentDeliveryNetworkUrl method to set the Url of the web asset group to point to that CDN.
Question: What will happen if a web asset group contains both Telerik's native assets and my custom assets?
Answer: When a group contains both Telerik and user-defined assets the Telerik's assets will be served first then the custom assets. If combine/caching/compression is set for this asset group, it will only apply to the custom assets.
Question: When NOT to use Telerik CDN?
Answer: Intranet applications in particular are a bad candidate for it. Your Intranet is likely to be a lot faster than any type of CDN. You'll also lose the ability to run your application without an Internet connection. Some corporate firewalls may also deny requests to CDN URLs.