Expected Behaviour?
That, I can't tell you. My first thought was, that the ETAG on a media request would be set to the Revision
field of the underlying item. That's not what happens.
Here is the snippet of code responsible, inside MediaRequestHandler
, under the SetMediaHeaders()
method.
cache.SetETag(media.MediaData.MediaId);
So basically it takes the MediaId
of the underlying Media blob. Not the Media Item itself.
This seems 100% in line with what you're experiencing yourself - updating the Media will provoke a new ETAG. Updating meta information on the image, will not.
But isn't this good enough anyway?
You're trying to prevent a re-download of expensive media data, and if the data hasn't changed (the media itself) - the ETAG should stay the same? no?
I mean, if you output additional meta information about the media on your page - this would come from the Media Item itself and not be restricted by caches.
In summary
I think this works as intended and expected. ETAG updates when the media is updated, not the media meta information.
Workaround, if you want
The method responsible for the ETAG header (and all other headers) is SendMediaHeaders
on the MediaRequestHandler
. It is implemented as a protected virtual
method, so it would be relatively easy for you to override this behaviour if you still require it. Write a new class that overrides this method, and replace the default Sitecore one in Web.config
under <handlers>
.
<add verb="*" path="sitecore_media.ashx" type="Sitecore.Resources.Media.MediaRequestHandler, Sitecore.Kernel" name="Sitecore.MediaRequestHandler"/>