Skip to end of metadata
Go to start of metadata

Benefits

IMS has been designed to work in conjunction with Content Delivery Networks (CDNs). CDNs can improve the performance of the site for end users in a number of ways:

  • Different sources of content are loaded simultaneously by browsers
  • CDNs can cache data near to users, and return it quickly
  • CDNs expand the total amount of bandwidth available to the site

The main pages of an IMS site cannot be served over a CDN, as they are dynamic, however thumbnails, previews, video streams and published files can - and these represent the majority of requests and data transfer.

Browsers will typically download up to two URLs at a time from the same host name: some pages in IMS (like thumbnail views) may include hundreds of images. By using four host names, browsers will download up to eight at a time, which significantly increases the speed of loading the page (each file is quite small, so most of the time is lost in connecting and getting a response, rather than being limited by bandwidth).

Types of CDN

There are two main types of CDN: pull-based and push-based (most CDN operators offer both). IMS only supports pull-based mode: this works as follows:

  • End users request a URL from their local CDN location
  • If the CDN server has a copy of it already, it sends it to the user
  • Otherwise, the CDN server sends on a request to the 'Origin Server' (IMS), which sends back the file
  • The CDN server caches this response, and sends it on to the user

Push based CDNs require that the content is actively sent to the CDN before it can be requested: this is not compatible with an on-demand system like IMS.

Pseudo-CDNs

You can obtain some of the benefits of using a CDN without subscribing to a CDN service by adding additional DNS aliases to your IMS server (or a reverse-proxy in front of it).

Content requested from each of these will be treated by the browser as if it were coming from different servers, so the browser will load more at the same time.

To use this approach, add DNS CNAMEs to your IMS server, and then follow the instructions below using those addresses as the URL stub.

Configuring IMS to use a CDN

When you subscribe to a CDN service, you will be given one or more URL stubs (e.g. http://a.mycompany.cdn.net, http://b.mycompany.cdn.net, http://c.mycompany.cdn.net, http://d.mycompany.cdn.net). In the configuration, you would specify the origin servers, based on the host name or path - so you might set it up such that http://*.mycompany.cdn.net/ims/ uses http://ims.mycomany.com/ as its origin server.

Next, you need to configure IMS to use these URLs as the source of thumbnails, etc.. To do this, create or edit the file /opt/thirdlight/ims/configuration/ims.ini.local and add the details:

<?php

$g_STATIC_URLS = array("http://a.mycompany.cdn.net/ims/", "http://b.mycompany.cdn.net/ims/", "http://c.mycompany.cdn.net/ims/", "http://d.mycompany.cdn.net/ims/");

Finally, run dpkg-reconfigure ims6 to apply the change.

These URLs will only be used for non-SSL pages in IMS - loading resources over an insecure connection to a secure page raises browser warnings.

Using SSL with CDNs

As of IMS v6.0.15, you may specify CDN URLs for secure (SSL) pages. This is performed similarly:

<?php

$g_STATIC_URLS = array("http://a.mycompany.cdn.net/ims/", "http://b.mycompany.cdn.net/ims/", "http://c.mycompany.cdn.net/ims/", "http://d.mycompany.cdn.net/ims/");
$g_STATIC_SSL_URLS = array("https://a.edge.cdn.net/mycompany/ims/", "https://b.edge.cdn.net/mycompany/ims/", "https://c.edge.cdn.net/mycompany/ims/", "https://d.edge.cdn.net/mycompany/ims/");

Note that the SSL URLs may be of a different form to the unencrypted ones: check with your CDN provider.

URL selection

  • When both g_STATIC_SSL_URLS and g_STATIC_URLS are configured, IMS will choose the one matching the protocol of the current page (so the SSL URLs will only be used from secure pages). This can be of benefit if your CDN provider charges more for content delivered over SSL.
  • If only g_STATIC_SSL_URLS URLs are specified, they will be used for all pages
  • If only g_STATIC_URLS are specified, they will only be used for non-secure pages. Secure pages will have content delivered directly from the IMS server over SSL.

Please note that while you can use HTTPS URLs for g_STATIC_URLS, you must not use HTTP URLs for g_STATIC_SSL_URLS

  • No labels