The best solution I found, to force the browser cache to refresh for an image, is to modify the image url in the html.

Example:
I have an image with this url: “/images/mario-profile-photo.jpeg”.
Change the url to: “/images/mario-profile-photo.jpeg?updated={DateTime.Now.Ticks}“.

So, I lied, sorry! This will make the browser request the image again, because the url is different. It doesn’t really refresh the cache.

Using DateTime.Now.Ticks will force the refresh every time the page loads, so I don’t recommend using it.

If you have the time of when the photo was last updated, use that instead! Something like: {Photo.UpdateDate.Ticks}
This way, you will only request a new image when it is different from the one you already have in cache.

Note: the “?updated=” property is just a name, you can use whatever you want. The important thing is to modify the url.

For Umbraco developers: When saving an image, do not forget to set it’s UpdateDate! Umbraco doesn’t update that property automatically.

Hope this helps,
Thanks for reading!
Mário

1 COMMENT

LEAVE A REPLY

Please enter your comment!
Please enter your name here