A Content Delivery Network (CDN) can improve the performance of your websites running in the Azure environment. By replicating the contents of your Blob storage across multiple data centers around the world, Azure CDN can speed up delivery of static content, such as images or stylesheets, as well as streaming media. See Getting started with Azure CDN for details.
You can utilize an Azure CDN service for Kentico projects configured to use Azure storage and for Kentico Azure projects running in Cloud Services. To start using a CDN for your project, you need to:
- Create a CDN service profile on the Azure Management Portal.
- Add CDN endpoints to the created profile.
- Enable the CDN in Kentico
Creating a new Azure CDN profile
- Open the Azure Management Portal.
- Click New -> Web + Mobile -> CDN -> Quick create.
- Fill in the CDN Profile
- Enter a name.
- Select a Subscription.
- Select a Resource Group or create a new one.
- Select a pricing tier.
- Click Create.
Adding CDN endpoints to the Azure CDN profile
- Open the created Azure CDN profile.
- On the Overview tab, click the Endpoint button, the Add an endpoint dialog window opens.
- Enter a name.
- Select the Origin type of the service you want to use the CDN for.
- Select the service from the Origin hostname drop-down list.
- (Optional) Set a custom path to the content you want distributed over the CDN.
- (Optional) Set a custom host header.
- Specify the protocol and port your service runs on (by default, all Azure services use the default HTTP and HTTPS ports)
- Click Add.
Note that it may take up to 90 minutes for the new endpoint to propagate through the CDN network. You may receive error code 400 (Bad Request) errors during this time.
Configuring Kentico to use a CDN
After you create a CDN using the management portal, you need to register the CDN in your Kentico project to start using this service.
- Open the web.config file of your local project.
Add the CMSAzurePublicContainer and CMSAzureCDNEndpoint keys into the web.config file:
<appSettings> <add key="CMSAzurePublicContainer" value="true" /> <add key="CMSAzureCDNEndpoint" value="EndpointURL" /> </appSettings>
Replace EndpointURL with the name of your created CDN endpoint – in the Azure Management Portal, open your Azure CDN profile and locate the hostname of the endpoint associated with your application.
If your site runs under HTTPS, we recommend you always specify the EndpointURL using the HTTPS protocol as well.
Not doing so may result in Mixed Content warnings being logged in your web browser's console when retrieving files from the CDN.
Your project is now ready to use the created Azure CDN service. If your site is running on Azure, a full redeployment of your project to the Azure platform is necessary.
Azure CDN content caching
The expiration interval for Azure CDN cache can be defined by the following values:
- By the CMSAzureCDNCacheMinutes web.config key.
- By the Cache files (minutes) setting in Settings -> System -> Performance.
- By the default value defined by Azure.
- See the Azure documentation: Manage expiration of Azure Storage blobs in Azure CDN
This list is ordered by priority, which means that the default Azure value can be overwritten by configuring the Cache files (minutes) key. And this setting can be overwritten by the CMSAzureCDNCacheMinutes web.config key.
If you set the setting and the web.config key to 0 or an invalid value, the default Azure CDN value will be used.