---
title: "CDN setup considerations"
slug: "cdn-setup-considerations"
abstract: "Find CDN setup configurations, including important settings to consider whether you set up a CDN yourself or have Sitecore set it up for you."
---
# 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](https://azure.microsoft.com/en-us/pricing/details/cdn/). Other considerations also include the different [Azure CDN product features](https://docs.microsoft.com/en-us/azure/cdn/cdn-features) and the [Azure CDN point of presence (PoP) locations by region](https://docs.microsoft.com/en-us/azure/cdn/cdn-pop-locations).

> [!note]
> 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](https://docs.microsoft.com/en-us/azure/cdn/cdn-rules-engine) on the Microsoft website, where you can find caching rules for [other vendors](https://docs.microsoft.com/en-us/azure/cdn/cdn-caching-rules-tutorial) 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](https://docs.microsoft.com/en-us/azure/cdn/cdn-create-new-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](https://docs.microsoft.com/en-us/azure/cdn/cdn-query-string).

    > [!note]
    > Your 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](https://docs.microsoft.com/en-us/azure/cdn/cdn-caching-rules#caching-behavior-settings). 

    > [!note]
    > If you need to clear your cache after publishing, you can [manually purge CDN caches in your Azure Portal](https://learn.microsoft.com/en-us/azure/cdn/cdn-purge-endpoint), or programmatically by sending a [REST API call to Azure CDN](https://learn.microsoft.com/en-us/rest/api/cdn/endpoints/purge-content?view=rest-cdn-2024-02-01&viewFallbackFrom=rest-cdn-2023-05-01&tabs=HTTP). 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: 

- [Optimize Azure CDN for the type of content delivery](https://docs.microsoft.com/en-us/azure/cdn/cdn-optimization-overview)
- [Control the Azure CDN caching behavior with caching rules](https://docs.microsoft.com/en-us/azure/cdn/cdn-caching-rules)
- [Add a custom domain to your Azure CDN endpoint](https://docs.microsoft.com/en-us/azure/cdn/cdn-map-content-to-custom-domain)
- [Configure HTTPS on an Azure CDN custom domain](https://docs.microsoft.com/en-us/azure/cdn/cdn-custom-ssl?tabs=option-1-default-enable-https-with-a-cdn-managed-certificate)