CDN setup considerations
If you are considering setting up a Microsoft Azure® Content Delivery Network (CDN) for the Sitecore Media Library, using either Azure Marketplace or Sitecore Azure Toolkit, you can choose between having Sitecore set up a CDN for you, or bringing your own CDN.
If you are considering setting up a CDN manually (without using Azure Marketplace or Sitecore Azure Toolkit), you will need to set up a CDN yourself.
Considerations when Sitecore sets up a CDN for you
When Sitecore sets up a CDN for you, using Azure Marketplace or Sitecore Azure Toolkit, you can choose the pricing tier through Content Delivery Network pricing. Other considerations also include the different Azure CDN product features and the Azure CDN point of presence (PoP) locations by region.
In some cases, you might need to set up some of the pricing tiers post-deployment. If so, refer to the information in Azure Marketplace or Sitecore Azure Toolkit (depending on your deployment method).
If you are using Sitecore Azure Toolkit then refer to the caching rules for Premium Verizon on the Microsoft website, where you can find caching rules for other vendors as well.
Considerations when you set up a CDN yourself
If you set up a CDN yourself, you can use the CDN endpoint URL to set up the Sitecore Media Library to use a CDN. You can use any CDN provider, including Azure CDN. To set up an Azure CDN yourself, work through Quickstart: Create an Azure CDN profile and endpoint.
When you set up a CDN endpoint, regardless of which CDN provider you use, ensure that you:
-
Cache every unique URL - The CDN endpoint must be configured to cache every unique media URL, including the path and query string. When Sitecore creates a link to a media item, it uses the revision number in the query string (rev) as a cache key. This means a new media URL is generated with each revision of an item, preventing the CDN from returning old revisions. The media URL shown in your Sitecore pages is automatically updated with a newer query string (rev) when the media item is published. To enable caching for every unique URL for an Azure CDN endpoint, see Control Azure CDN caching behavior with query strings - standard tier.
NoteYour CDN endpoint caches aren't affected by this behavior: the media URL with the older query string (rev) is still accessible until it expires. You can choose to clear your CDN cache if needed.
-
Respect existing cache headers in the response - The CDN endpoint must be configured to respect the cache headers, (if they exist). When the Sitecore media request handler responds to a request, it sets the cacheability, max-age, and expiration cache headers. This means, for example, that the media request handler will set all non-public items, to private to prevent caching a non-public item on a CDN. To set up cache behavior settings for an Azure CDN endpoint see Caching behavior settings.
NoteIf you need to clear your cache after publishing, you can manually purge CDN caches in your Azure Portal, or programmatically by sending a REST API call to Azure CDN. If the value of Caching behavior for an Azure CDN endpoint is missing, you must set it to
Not set
.
The next steps (optional)
After you or Sitecore set up an Azure CDN, you may want to: