Whilst testing a Sitecore 6.1 site due for release Firebug highlighted some unexpected behaviour from the Sitecore Media Request Handler which takes care of responding to requests for items held in the Sitecore Media Library. Media library items were being returned in full every time that they were requested, each returning a HTTP 200 response status code.
Further digging with Lutz Roeder’s excellent Reflector tool showed that the If-Modified-Since request header field was not being responded to correctly by the MediaRequestHandler. The If-Modified-Since request header is a HTTP-date value whose time component is in the format HH:MM:SS (i.e. no milliseconds). This header field value is used by the Modified method within the MediaRequestHandler to compare to the System.DateTime value that the media library item was last updated. As a System.DateTime value includes a milliseconds component the equality check fails for the majority of media library requests and as a result the item is downloaded to the browser in full.
Sitecore have confirmed that this is a known issue and something that will be fixed in a forthcoming release. In the meantime it’s not difficult to patch in a modified HTTP handler to respond to media library requests and implement HTTP 304 response handling appropriately. Alex de Groot has a good article on his blog that explains how Sitecore interacts with HTTP handlers for media handling.
Just spotted the same thing myself on a customer site using the most excellent Redbot (www.redbot.org).
All the .ashx image assets failed the IMS (if-modified-since) test.
I’ve been meaning to follow up on this to see whether Sitecore have pushed a fix out for this into their current release. If it’s still broke I can put up my patched version of the media handler if it’s of use.
Thanks Kevin – if you could post up what Sitecore says that would be great. I don’t have access to Sitecore support myself. Hopefully the client will chase it direct too.
Steve, this problem has been resolved with the release of Sitecore CMS 6.4.1 rev.110324 (6.4.1 Update-1) on March 28, 2011.
According to the release notes there’s a whole pile of issue fixes and improvements in the area of the Media API. Here’s the Sitecore reference for the fix that you’re interested in:
Please be aware that Sitecore CMS 6.4.1 rev.110324 (6.4.1 Update-1) is not Sitecore’s current recommended version, as such is not recommended for a production installation that runs an important website for a customer. The current recommended version is Sitecore CMS 6.3.1 rev.110112.
6.4.1 became the recommended Sitecore release version on 05/08/2011.
Pingback: Media Library status code 200 Vs 304 « Sitecore basics!