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 www.litium.se and a CDN is created with the domain cdn.litium.se. For every request sent to cdn.litium.se, where the CDN does not have the requested file, the CDN downloads the file from www.litium.se 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, cdn.litium.se.

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 www.cdnfinder.com 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 appsettings.json.

  1. Open the appsettings.json.
  2. Add the domain name to CdnHosts in Section: Litium / MediaLocation . The element should now look like this:
     "MediaLocation": {
          "CdnHosts": [
            "http://cdn.litium.se"
          ]
    }
    

    (replace http://cdn.litium.se​ with your CDN domain name) 

  3. Save and close your appsettings.json.

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., cdn1.litium.se, cdn2.litium.se, cdnN.litium.se 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 you simply put multiple hosts, in the CdnHosts separated by commas (,). Litium is built to spread the requests among the CDN hosts but always use the same host for the same file.

Was this page helpful?
Thank you for your feedback!