Configure CDN for blob storage providers

You can configure a Sitefinity CMS blob storage provider to work with CDN. When configured this way, Sitefinity CMS serves all media content managed by this provider through the CDN URL. This results in content going to the client through the CDN, and brings the benefits of faster content delivery and CDN caching. 

This is made possible since each blob storage provider returns relative URLs for the media content items it stores. By default Sitefinity resolves these URLs to your website domain (for example https://www.mysite.com) and returns media content URLs from that domain (for example https://www.mysite.com/sf-images/default-source/default-album/myimage.png). When you configure CDN parameters for the blob storage provider, Sitefinity CMS resolves the URL of the media content using for the specified CDN URL (for example https://www.cloudfront.net/sfimages/default-source/default-album/myimage.png).

RECOMMENDATION: When you configure CDN for an existing blob storage provider, all content, managed by this provider will be served through the CDN. Keep this in mind in case you have some internal content you would't like to make available via CDN. We recommend to create a new blob storage provider and configure the CDN settings, create new library that will use it, and move the public items from default library to the new library.

Additionally, when using external blob storage providers, for example Azure or Amazon, we recommend using the external blob storage provider's CDN option, instead of configuring a CDN for an external blob storage provider on Sitefinity CMS level.  

NOTE: Sitefinity's blob storage providers work with images, videos and documents (the default Sitefinity CMS provider works with all three of these item types). By adding the CDN parameters to a provider all of its item types will be served through the CDN. If this is your intended scenario, make sure your CDN can handle the different item types of the provider.

Add CDN parameters to an existing blob storage provider

To configure CDN for your blob storage provider you need to edit the provider settings and add a new parameter instructing the provider to use CDN and what is the CDN URL. To do this perform the following procedure:
  1. Navigate to Administration » Settings » Advanced » Libraries » Blob storage » Blob storage providers.
  2. Expand the node of the blob storage with which you want to use CDN and click Parameters » Create new.
  3. In the Key field enter cdn
  4. In the Value field enter the URL of your CDN.
    For example: http://myaccount.cloudfront.net

    IMPORTANT: When you use the Amazon blob storage provider, the protocol is automatically deduced based on the used bucket protocol. Therefore, you must omit the protocol part of the URL. For other CDN providers, such as Azure, database or file system, you need to specify the protocol part of the URL.

  5. Click Save changes.
  6. Restart your Sitefinity CMS application.

As a result, your provider now uses CDN.

Configure a library to use blob storage provider that has CDN enabled

You can change the blob storage provider for an existing library by performing the following:

  1. Click the Actions link of the library whose items you want to use the blob storage provider with CDN. From the dropdown, select Move to another storage.
    In the Blob storage provider dropdown box all available storage providers appear.
  2. Select the desired blob storage provider and click Move Library.

As a result, your library is configured to use the CDN blob storage provider and content items from that library are retrieved from the CDN.

NOTE:

If you activated the Web security module and have images or other media on your website that are served from another domain like Azure or Amazon Web Services, you must add the domain names in the module’s HTTP response headers. To do so:

  1. Navigate to Administration » Settings » Advanced.
  2. In the tree on the left, expand WebSecurity » HttpSecurityHeaders » ResponseHeaders.
  3. Under Content Security Policy, for images add the domain next to the img-src headers and for videos – next to the media-src header.

For more information, see Web security module.

Increase your Sitefinity skills by signing up for our free trainings. Get Sitefinity-certified at Progress Education Community to boost your credentials.

Web Security for Sitefinity Administrators

The free standalone Web Security lesson teaches administrators how to protect your websites and Sitefinity instance from external threats. Learn to configure HTTPS, SSL, allow lists for trusted sites, and cookie security, among others.

Foundations of Sitefinity ASP.NET Core Development

The free on-demand video course teaches developers how to use Sitefinity .NET Core and leverage its decoupled architecture and new way of coding against the platform.

Was this article helpful?