For Umbraco v8 Azure CDN integration use Slimsy v3 - documentation at https://github.com/Jeavon/Slimsy/blob/dev-v3/Docs/Azure-CDN/index.md
The AzureCDNToolkit package allows you to fully utilise and integrate the Azure CDN with your Umbraco powered website using a "Origin Push" approach.
To Push or to Pull You can use both a Push or a Pull origin approach to the Azure CDN with Umbraco since the release of the new Azure CDN (AzureEdge), this package supports only Push origin (storage) currently however it maybe extended to also support Pull in the future.
There are three file types that should be served from CDN if you have one.
- Assets - css, js & static images used by templates etc..
- Images managed by Umbraco - cropped or not
- Files - pdfs, docx etc
The toolkit depends on two packages being installed, these are the UmbracoFileSystemProviders.Azure and the ImageProcessor.Web Azure Blob Cache plugin
Once installed and setup the package provides UrlHelper methods to use for resolving url paths for assets and Image Cropper urls and also a value converter for the TinyMce editor so that images within the content are also resolved.
Some examples:
@Url.ResolveCdn("/css/style.css")
@Url.GetCropCdnUrl(Umbraco.TypedMedia(1084), width: 150)
<div class="brand" style="background-image: url('@Url.ResolveCdn(home.GetPropertyValue<string>("siteLogo") + "?height=65&width=205&bgcolor=000", false, false)')"></div>
When using these methods, the toolkit will attempt to resolve the urls to their absolute paths and crucially ensures that a cache busting querystring variable is added. Without the cache busting using the Azure CDN can become tricky when you want to update with new content. This has the added benefit of avoiding your site needing to handle any 301 redirects and also gets some optimisation benefit (PageSpeed etc).
Some examples:
<link rel="stylesheet" type="text/css" href="/css/bootstrap.min.css">
<img src="/media/1052/jan.jpg?anchor=center&mode=crop&width=150&rnd=131070397620000000"/>
<a href="/media/1050/blank.docx">Download Word Doc</a>
Becomes:
<link rel="stylesheet" type="text/css" href="https://azurecdntoolkitdemo.azureedge.net/assets/css/bootstrap.min.css?v=0.0.1">
<img src="https://azurecdntoolkitdemo.azureedge.net/cloudcache/e/0/2/7/d/2/e027d2acab49ab523db3ece72c0651310dd3320c.jpg"/>
<a href="https://azurecdntoolkitdemo.azureedge.net/assets/media/1050/blank.docx?rnd=131070387800000000">Download Word Doc</a>
Note: this package is not compatible with Slimsy v1 (it should work with the upcoming Slimsy v2 using img srcset)
Both NuGet and Umbraco packages are available.
NuGet Packages | Version |
---|---|
Release | |
Pre-release |
Umbraco Packages | |
---|---|
Release | |
Pre-release |