Developer considerations for the Sitecore Media Library CDN support
This reference contains information about settings, pipelines, and details which relate to Sitecore Media Library Content Delivery Network (CDN) support.
Getting a CDN-enabled Media Item URL
When you use a CDN for the Sitecore Media Library, the media item URLs of a page must be absolute URLs that start with a CDN URL, otherwise the Sitecore CD server will respond to every request instead of just the CDN server.
To ensure that Media Item URLs respect the Sitecore Media Library, you can use the settings in the following table to address the media item.
Setting |
Description and code sample |
---|---|
|
Use RequestResponse
|
|
If the item has an Image field, you can use the RequestResponse
|
|
If the item has an Image field, you can use the RequestResponse
|
|
If the item has a Link field or an Image field, you can use this tag to render the link so it has a CDN-enabled URL. RequestResponse
|
Media items in RichText fields |
If you use the rich-text editor to insert a MediaItem in a RichText field, the media item will be rendered using a CDN-enabled URL at run-time. |
If you are using the Sitecore Content Editor and at run-time want a media item to be rendered by using a CDN enabled URL, then do not use any of the settings in the table above. Instead, use the rich text editor to insert a MediaItem in a RichText field.
Pipelines and processors
The pipeline getMediaUrlOptions
impacts on the generation of Media Item URLs, and the getResponseCacheHeaders
pipeline impacts on setting response cache headers.
Other modules may add some processors depending to the requirements.
getMediaUrlOptions
Using this pipeline, you can add processors to get media URLs and control the way a URL is generated for a media item. For example, when developers call a MediaManager.GetMediaUrl
they can manipulate MediaUrlOptions
in the processors. In this pipeline, the following processors impact on AlwaysIncludeServerUrl
:
-
SecurityProcessor
- This applies security concerns toMediaUrlOptions
that have been provided by the pipeline argument. If the item is not publicly readable,SecurityProcessor
sets the value ofAlwaysIncludeServerUrl
tofalse
, unless it has been explicitly assigned by developer code or another pipeline. -
SiteModeProcessor
- This applies site mode concerns toMediaUrlOptions
that have been provided by the pipeline argument. If the site mode is not normal, it setsAlwaysIncludeServerUrl
tofalse
.
getResponseCacheHeaders
This pipeline is responsible for providing response cache headers. The following processors impact on the cache headers for a media request:
-
RequestTypeDetectionProcessor
- This detects the request type, if the request type has not been specified. -
MediaRequestArgsInitializerProcessor
- This initializes thegetResponseCacheHeaders
that have been provided by the pipeline argument for a media request. The values are determined by the Sitecore Media Response configurations in theSitecore.config
file. -
PublishingProcessor
- This applies publishing concerns on cache headers when creating a response. This processor sets cacheablity and the expiration date based on the publishing information of the item. If the item does not have any publishing date restrictions, both the expiration date and the max-age are determined by the Sitecore Media Response configurations in theSitecore.config
file. If an item has a publishing date restriction, the expiration and max-age is set so as not to exceed the maximum publish date of the item. -
SecurityProcessor
- This applies publishing concerns on cache headers when creating a response. If the item is not publicly readable, the processor sets cacheability none and set cache asexpired
.