Virtual Happy Hour this month, Jun 28, we'll be getting a sneak preview at our soon to launch SaaS CMS!

Try our conversational search powered by Generative AI!

Per Bjurström
Mar 18, 2009
(1 votes)

CdnSupport module preview

“A content delivery network or content distribution network (CDN) is a system of computers networked together across the Internet that cooperate transparently to deliver content most often for the purpose of improving performance, scalability, and cost efficiency, to end users.” - Wikipedia

This is the CdnSupport module used in Mats & Peters presentation on the EPiServer Day on client-side performance. It is an unsupported module that you can download in binary form and try yourself, it will probably end up either as an open open-source module or as part of the product.

Offloading the burden of delivering static files from the web server is one way of scaling out your system, its better to have one system optimized for delivering static content and another optimized for delivering dynamic content, right ? Another reason is that you want your static content cached closer to the user, hence making your site more responsive.

How does it work ?

It rewrites URL’s from:

The “mydomain“ is your CDN and the strange characters in the middle is the changed date of the file in hexadecimal form.

If you are using a CDN your file may end up cached on a server across the globe and it won’t get evicted until it expires (for example 1 day). That is why the module injects the changed date into the URL, as soon as you change the file the URL changes and you get fresh copies of the file. Simple but effective, thanks Tom Stenius for the idea.

Remember that most cache servers and CDN’s require you to set valid expiration date on your files to actually cache anything, this module will not do that for you.

Do I need a CDN to test this module ?

No, you can point it back to the origin site if you like to test it (or just utilize the fact that a browser limits the number of ports per domain name). You can also use a caching server like Varnish.

What CDN’s are supported ?

This module has been tested with EdgeCast and Akamai but should work with most of them like Limelight Networks etc. There are many others but some such as CacheFly only supports files stored on their servers so make sure they support “customer origin” if you are using this module.


Links that it cannot get the changed date for are ignored. It also does a security check on VPP-files to make sure Everyone has Read access since the CDN will not be able to fetch it otherwise (they normally don’t forward cookies etc). If you are using files protected by some other mechanism this module will not work correctly.


URL’s are rewritten using the existing infrastructure of events in EPiServer CMS. A custom cache is used to speed up the changed-date lookup since there can be large amounts of resources per page that need to be parsed. The cache stores lookups for 10 minutes and up to 10,000 entries using a LFU-scheme for eviction.


You can add “?cdn=off” to the URL to disable rewriting if you a member the Administrators group. You can also add “?cdn-microcache=debug” to see statistics on the custom cache.

Edit mode

This module will not rewrite any URL’s originating from a preview in edit mode or when you supply a version of a page.


There are three known areas that need more work:

  • Need more performance testing on how this module affects the site, I've only done performance testing in unit tests and on Labs.
  • There is no way to have different settings for different folders with static files, you can only have different settings for different templates by using the location-element.
  • The internal cache will not expire instantly in load balanced scenarios (the changed date in the URL, not the actual file which get updated).


1.    Add config-section (configuration->configSections):

   1: <section   name="cdnSupport" 
   2:            type="EPiServer.CdnSupport.CdnSupportSection, EPiServer.CdnSupport" 
   3:            allowLocation="true"/>

2.    Add the actual config: 

   1: <cdnSupport enabled="true" 
   2:             url="http://cacheserver" 
   3:             timestamp="true" 
   4:             extensions="*" />

3.    Drop the DLL in bin-folder
4.    Under Modules add this after the UrlRewriteModule:

   1: <add name="CdnSupport" 
   2:      type="EPiServer.CdnSupport.CdnModule, EPiServer.CdnSupport" 
   3:      preCondition="managedHandler"/>



Mar 18, 2009


Sep 21, 2010 10:32 AM

I must say that this is a piece of art. According to the yahoo performance guidelines 80%-90% of the end-user response time is spent downloading components. This is a fact you should consider if you're looking for a dynamic cdn solution - a solution that probably will be much more expensive and have drawbacks for example regarding personalization.

Sep 21, 2010 10:32 AM

Very nice indeed! This is great news for sites with global reach! Any plans for adding support for for Amazon CloudFront??

/ Flalar

Sep 21, 2010 10:32 AM

Not really, since CloudFront requires S3 (as far as I know). That would require some kind of syncing or virtual path provider for CMS<->S3. The current implementation assumed you store the files locally and use the CDN as a cache.

Lars Flågan
Lars Flågan Sep 21, 2010 10:32 AM

Yupp, have been puzzling on the thought of using S3 as a file store for EPiServer… Might not be demand for such a solution but it sure would be a nice little personal r&d project

Sep 21, 2010 10:32 AM

It sure sounds like a cool project!

Please login to comment.
Latest blogs
Remove a segment from the URL in CMS 12

Problem : I have created thousands of pages dynamically using schedule jobs with different templates (e.g. one column, two columns, etc..) and stor...

Sanjay Kumar | Jun 21, 2024

Copying property values part 2

After publishing my last article about copying property values to other language versions, I received constructive feedback on how could I change t...

Grzegorz Wiecheć | Jun 18, 2024 | Syndicated blog

Enhancing online shopping through Optimizely's personalized product recommendations

In this blog, I have summarized my experience of using and learning product recommendation feature of Optimizely Personalization Artificial...

Hetaxi | Jun 18, 2024

New Series: Building a .NET Core headless site on Optimizely Graph and SaaS CMS

Welcome to this new multi-post series where you can follow along as I indulge in yet another crazy experiment: Can we make our beloved Alloy site r...

Allan Thraen | Jun 14, 2024 | Syndicated blog

Inspect In Index is finally back

EPiCode.InspectInIndex was released 9 years ago . The Search and Navigation addon is now finally upgraded to support Optimizely CMS 12....

Haakon Peder Haugsten | Jun 14, 2024

Change the IP HTTP Header used for geo-lookup in Application Insights


Johan Kronberg | Jun 10, 2024 | Syndicated blog