Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at

  • Shaishav Karnani from 353 posts 1637 karma points
    Jul 30, 2020 @ 06:24
    Shaishav Karnani from


    We are integrating Azure CDN with Umbraco. CDN is integrated and we have written helper method to make a CDN external call. However, we need to include cache-busting technique too.

    This was possible in Umbraco v7 using below package.

    How can we do it using v8? Looking forward for your views.



  • David Armitage 485 posts 2042 karma points
    Aug 01, 2020 @ 03:06
    David Armitage

    Hi Shaishav,

    Could you possible try something simple like for example.

    Store a cache busting number within your web config. Call it something like ImageCacheVersion.

    Then when you are referencing the image urls just add a query string on the end of the url.

    .media/[email protected](ImageCacheVersion)

    That way when you change the value in the web config then the URL is going to be different and so shouldn't be returned from the Cache.

    A simple idea but it will be checking that a query string is allowed by Azure CDN. My guess is it will be fine.



  • Amir Khan 1275 posts 2708 karma points
    Aug 03, 2020 @ 19:20
    Amir Khan

    Where in the web.config would you put this and what would the xml look like? This could be interesting to easily version up js / css as well, just not sure exactly how to implement it.

  • David Armitage 485 posts 2042 karma points
    Aug 04, 2020 @ 11:40
    David Armitage

    Here is an example of the web.config. This should get added into the appSettings section. As you can see I have added a cache busting property at the bottom.

    <add key="Umbraco.Core.DefaultUILanguage" value="en-US" />
    <add key="Umbraco.Core.UseHttps" value="false" />
    <add key="ValidationSettings:UnobtrusiveValidationMode" value="None" />
    <add key="ClientValidationEnabled" value="true" />
    <add key="UnobtrusiveJavaScriptEnabled" value="true" />
    <add key="webpages:Enabled" value="false" />
    <add key="enableSimpleMembership" value="false" />
    <add key="autoFormsAuthentication" value="false" />
    <add key="dataAnnotations:dataTypeAttribute:disableRegEx" value="false" />
    <!--<add key="owin:appStartup" value="UmbracoDefaultOwinStartup" />-->
    <add key="owin:appStartup" value="UmbracoStandardOwinStartup" />
    <add key="Umbraco.ModelsBuilder.Enable" value="true" />
    <add key="Umbraco.ModelsBuilder.ModelsMode" value="Nothing" />
    <add key="Umbraco.ModelsBuilder.EnableApi" value="true" />
    <add key="CacheBuster" value="1000" /><!-- version number -->

    And here is code to be able to read from the web.config. ConfigurationManager.AppSettings["CacheBuster"]

    More info can be found here.

    If you pop the a query string on the end of the image I think that should work.

    So the image might look something like.


    And the version 1000 will be read from your new web.config setting. When you want to get a fresh image without using the cache then increase the version number in your web.config to 1001, 1002, 1003 and so on.



  • Amir Khan 1275 posts 2708 karma points
    Aug 04, 2020 @ 16:55
    Amir Khan

    Thank you!!

Please Sign in or register to post replies

Write your reply to: