Azure CDN for Sitecore
What is CDN?
In simple words the website and assets are cached in multiple servers across the world. When a user visits the site they are served from the nearest server to their location to reduce latency and improve load times.
Why to use CDN?
The CDN helps in reducing the latency and download time. Since CDN will be a different domain, Help in concurrent download of assets.Improves page load time that gives a better User Experience. Having a better position in search engines. The number of website visitors who turn to customers.
- Improve page load speed
- Handle high traffic loads
- DDos attack prevention
- Reduce bandwidth consumption
- Higher conversion rates
Every Second Counts
Studies show that a second-long delay causes a 7% drop in conversions, an 11% drop in page views and a 16% drop in customer satisfaction.
Types of Azure CDN
I am mainly focusing on the CDN offerings on Azure. The following offerings are provided in Azure as endpoints.
- Microsoft CDN (Classic)
- Standard Verizon
- Advanced Verizon
CDN Marketplace offering
The pricing is inexpensive compared to the value and speed that is provided by the Azure CDN.
Azure Content Delivery Network (CDN) includes four products:
- Azure CDN Standard from Microsoft (Classic)
- Azure CDN Standard from Akamai
- Azure CDN Standard from Verizon
- Azure CDN Premium from Verizon
Limits to 25 CDN Profiles per Subscription. Limit 25 Endpoint per profile. Limit 25 Domains per endpoint.
How to enable CDN with Sitecore?
The CDN works for public facing websites. The CDN needs to access and replicate the CD server. We can use CDN in two ways for Sitecore right out of the box
- Media library items
- Static assets
Media Library items
On the Sitecore Content Delivery (CD) server, go to the Sitecore deployment folder.
- In App_Config\Include, create a folder named CDN.
- In the CDN folder, create a file and name it: CDN.config
- Edit the CDN.config file and save the following information to the file:
How to setup Azure CDN?
Create a new resource by searching for CDN
Compare the offerings screen choose Explore other offerings and Azure CDN Standard from Microsoft
Common Error if you have not registered the CDN Resource provider in your subscription
Follow the instructions in the article and enable Microsoft.Cdn, it will take few minutes before you can use it.
Provide the information in the CDN profile creation page
Validation is passed review and create
Site will not be immediately available but will take some time depending on the size of the site.
First things to-do once created is to update caching rules by default its set to ignore the query strings. It needs to be updated to cache every unique URL that will help in reflecting the changes of media items when they are published.
Example URL of an image from Sitecore media library would be like the following
Its really important to enable that settings.
When the images or assets publised the revision guid in the Url should pull the new asset. If in case if you need to purge the CDN to force reload. Follow the purge option that could be done at the site level or a path.
The CDN can be setup with a custom domain and domain certificate will be provisioned without any additional cost for free by Microsoft.
If you have installed Dianoga it will support nextgen format webp. Azure CDN (Microsoft) Classic doesnt support it and Nehem has a solution for it in this article - https://www.nehemiahj.com/2022/08/sitecore-dianoga-with-azure-cdn.html
Subscribe to Bala Blog (bala.one) | Sitecore MVP | Sitecore | OrderCloud | Coveo | Azure
Get the latest posts delivered right to your inbox