Force image to reload (without appending a timestamp/random number to URL)

Force image to reload (without appending a timestamp/random number to URL)

Hello all,

I'd like to revisit the question of reloading images, as I have a situation that requires a different approach than what seems to be the most common method.  Typically, one adds a unique string as an additional parameter to the URL, thus making it a unique request and forcing the browser to retrieve a new result from the server.

However, this prevents the possibility for the server to return a 304 'not modified' response to the browser.  In my case, I need this capability for performance reasons in my application.  In my case, images are only modified on the server under certain conditions.  So I'd like the browser to be able to refresh images with the same URL...that way, it will only download new images if the server doesn't return a 304 response.

I have tried removing the image then creating a new image with the same properties.  I have also tried temporarily setting the image's src to point to a transparent pixel, then resetting it to the original image URL after the onload event.  In both cases, it seems that the browser does not re-request the image from the server.

Does anyone have any ideas about how this can be done?