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:
- Navigate to Administration » Settings » Advanced » Libraries » Blob storage » Blob storage providers.
- Expand the node of the blob storage with which you want to use CDN and click Parameters » Create new.
- In the Key field enter cdn
- In the Value field enter the URL of your CDN.
For example: http://myaccount.cloudfront.net
- Click Save changes.
- 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:
- 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.
- 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.
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:
- Navigate to Administration » Settings » Advanced.
- In the tree on the left, expand WebSecurity » HttpSecurityHeaders » ResponseHeaders.
- 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.