# Manually configure the Sitecore Media Library to use a CDN

Abstract

Manually set up the Sitecore Media Library so it can use a Content Delivery Network (CDN).

This topic describes how to manually set up the Sitecore Media Library so it can use a Microsoft Azure® Content Delivery Network (CDN). This is helpful if you have an existing on-premise or Azure-deployed Sitecore instance, and you want to enable the Sitecore Media Library to use a CDN.

### Note

If you are going to deploy a new instance of Sitecore XM or an XP scaled configuration on Azure, you do not need to set it up manually. Instead, you can use one of the following options:

Before you can set up the Sitecore Media Library to use a CDN, you must:

• Ensure you are running Sitecore XP and XM 9.1 or later.

You manually configure the Sitecore Media Library so it can use a CDN:

1. On the Sitecore Content Delivery (CD) server, go to the Sitecore deployment folder.

2. In App_Config\Include, create a folder named CDN.

3. In the CDN folder, create a file and name it: CDN.config

4. Edit the CDN.config file and save the following information to the file:

### Note

<?xml version="1.0" encoding="utf-8"?>

<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/">

<sitecore>

<settings>

<!--

MediaResponse.AlwaysIncludeServerUrl must be true, to always include CDN
url when getting media item url.

Otherwise, the request will
not be served by CDN server.

-->

<setting name="Media.AlwaysIncludeServerUrl">

<patch:attribute name="value">true</patch:attribute>

</setting>

<!--

MediaResponse.MediaLinkServerUrl must be set to url of the CDN endpoint.

Change it from http://example.com, to the url of the CDN
endpoint.

-->

<patch:attribute name="value">http://example.com</patch:attribute>

</setting>

<!--

MediaResponse.AlwaysAppendRevision should be true to always append
revision when getting media item url.

The purpose of the value is
to generate a unique URL for every revision.

-->

<setting name="Media.AlwaysAppendRevision">

<patch:attribute name="value">true</patch:attribute>

</setting>

<!--

MediaResponse.Cacheability
must be Public to let the CDN server cache the response.

the response, the CDN server will ask for the response from Sitecore server
every time.

-->

<setting name="MediaResponse.Cacheability">

<patch:attribute name="value">Public</patch:attribute>

</setting>

<!--

The max-age to use in media

CDN server uses this value as
max-age of the response cache.

-->

<setting name="MediaResponse.MaxAge">

<patch:attribute name="value">7.00:00:00</patch:attribute>

</setting>

</settings>

</sitecore>

</configuration>

### Note

You can also find this example configuration file under the root Sitecore folder in, App_Config\Include\Examples\CDN.config.example