Content Delivery Network Support (CDN)

Content Delivery Network (CDN) is a network with servers that reduces the network traffic to your primary server(s). A CDN network often has multiple servers and the different servers are placed around the world. You, as a client, will be using the server located closest to you, depending on your IP address. The reason is that data should be sent as short distances as possible to ensure the highest possible speed.

What is Content Delivery Network (CDN)?

There are many types of CDN. The two most common ones are described here.

  • The simplest one is when you manually upload files to the CDN, and then the CDN is served with the uploaded files.
  • The second one is called edge-caching, in which the CDN is automatically populated with files from an origin server. This means that the first request from PoPs (point of presence) downloads content from the main server.

    Example: The main site is and a CDN is created with the domain For every request sent to, where the CDN does not have the requested file, the CDN downloads the file from and caches it based on the cache-header included in the response. For all subsequent requests for the same file, the CDN already has the file cached and can serve directly with the cached content.

Does Litium support CDN?

Yes, Litium has built-in support for edge-cache CDN to reduce the number of requests for all anonymously accessible files and/or images stored inside the product. All requests not accessed by anonymous users will be served directly by Litium as before, to be able to access control of the files.

How does this work inside Litium?

When activating the CDN support for edge-cache all file links are re-written to include the domain name for your edge-cache domain, like in the example above,

I have static files in a folder on the site. Can I use edge-cache for them too?

Yes, you can. In Litium there is a built-in CDN filter that will parse the response and add a hostname to the static file names.

E.g. change tags from:

<img src="/ui/img/image.jpg" />


<img src="" />

How do I activate the CDN support?

Create an account at a CDN supplier

Start by creating an account at a CDN supplier and setup the CDN. The CDN should probably point directly to your main domain as origin server. Go to for a selection of CDN suppliers.

Configuration in Litium

After you have created your account at the CDN supplier you need to setup Litium. All configurations that you need to change are in the web.config. (If you don't intend to use the CDN filter you can skip those steps.)

  1. Open the web.config.
  2. Add the attribute useCdn="true" and cdnHost="" (replace with your CDN domain name) to the storage element. The element should now look like this:
    <storage cdnHost="" useCdn="true" />
  3. If your CDN supports secure content (https) you should also add the attribute useCdnForSecureContent="true", otherwise requests for secure content will not be directed to the CDN, in order to avoid broken images on your site. If your CDN for secure content is not the same as for non-secure content you can specify the secure content CDN with the attribute cdnSecureHost="".
  4. Find the element cdnFilter inside the section litium\studio. If the section is not found you should add the section and configure it with your settings. To be able to use this section the section needs to be declared in the declarations of the studio section with <section name="cdnFilter" type="Litium.Studio.Configuration.CdnFilterSection, Litium.Studio" />.
    	<add host="" secureContentHost="">
    		<add match="src=&quot;/WebResource.axd" />
    		<add match="src=&quot;/ScriptResource.axd" />
    	<add host="">
    		<add match="href=&quot;/ui/" />
    		<add match="src=&quot;/ui/" />
    		<add match="background-image:url('/ui/" insertAfter="'" />
    - The attribute secureContentHost is optional and if the attribute is excluded replacements when browsing secure content (https) pages are also excluded.
    - The attribute insertAfter is optional and if excluded the default " is used.
    In the above example we make several redirects to different hosts as an example for multiple matches to different hosts.
  5. Save and close your web.config.

Multiple domain hosts for CDN

If you need to speed up the loading of content from the CDN you can use several CDN's, e.g.,, to reduce the number of requests to a single hostname. Why should I use multiple CDN domains? Browsers are built to only make a limited number of simultaneous requests to each domain name. By using multiple domain names you can get faster response times.

To enable multiple hosts for storage you simply put multiple hosts in the cdnHost and/or cdnSecureHost attribute separated by commas (,). Litium is built to spread the requests among the CDN hosts but always use the same host for the same file.

Multiple domain hosts for CDN are only available for storage, not cdn-filter.

Was this page helpful?
Thank you for your feedback!