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.
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.
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.
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.
/images/image.png?version=1000
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.
Media - CDN Toolkit
Hi,
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. https://our.umbraco.com/packages/developer-tools/azure-cdn-toolkit-for-umbraco/
How can we do it using v8? Looking forward for your views.
Cheers,
Shaishav
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/whatever.png?version=@(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.
Regards
David
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.
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.
And here is code to be able to read from the web.config. ConfigurationManager.AppSettings["CacheBuster"]
More info can be found here. https://stackoverflow.com/questions/1189364/reading-settings-from-app-config-or-web-config-in-net
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.
/images/image.png?version=1000
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.
Regards
David
Thank you!!
is working on a reply...