Did you know about Media.AlwaysAppendRevision?

Yep, this is old news but apparently lots of people don’t know about this.

As you may know, when you replace an existing media item image with another one in Sitecore, if the new image is the same size as the older one, or if you are not appending the image dimension on the media item URL, you may run into a browser caching issue. That’s because even when you replace the image, the URL is the same. Therefore the browser will likely render the older version of the image because it is probably cached. If you’re using a CDN and think you’re safe from this issue, you’re not. This issue usually also affects your CDN, since it won’t be able to pull the updated image from the CD – again, because it is the same URL (at least until the CDN cache policy expires anyway).

So I was running into these issues and I noticed that the most common solution suggested for this is to override the Media Provider in order to append the revision and hash values as query string parameters to the media item URL. That way, every time the media item is updated, a new URL will be generated by the Media Provider for that media item, so cache problem solved!

This common solution is valid and great, but the good news is that starting on Sitecore 8.2 Update 5 there is a built-in setting that will do that for you:

<setting name="Media.AlwaysAppendRevision" value="false"/>

By default its value is false, if you set it to true you will start to see your media items URL looking something like this:

http://example.com/-/media/Products/Bags/B581.png?rev=bcf6a8ff80f74399bcdf024107173115&hash=633D10816CD7E62D5E8623D217F6296402D5B7BE

Note how out of the box, you will now get revision and hash values added to the URL.

Hope this helps!

Did you know about Media.AlwaysAppendRevision?
Tagged on:                     

2 thoughts on “Did you know about Media.AlwaysAppendRevision?

  • March 25, 2019 at 4:15 pm
    Permalink

    Thank you Geykel! This is a very valuable piece of information! I remember clients struggling often though with documents not being updated – last month catalog being presented, when intention is to have a new month catalog on the site for example. Question though: how do you satisfy SEO aspect for documents in Media Library, if it – as clients DO want the URL to stay the same, as it is also advertised in third party places and cannot be dynamic (with revision part added to it, etc)?

    Reply
    • March 25, 2019 at 4:20 pm
      Permalink

      I haven’t had that case before but what about using redirect rules for those medias they are using in third party vendors?

      Reply

Leave a Reply to Geykel Moreno Cancel reply

Your email address will not be published. Required fields are marked *