I am refreshing images via attr('src', newimage), where newimage may point to one of several images and may already be cached by the browser. Unfortunately the browser cache is being completely ignored when requesting through this method.
All images in this example are indeed being cached by the browser. When initially fetched from the server, the server returns correct 'Cache-Control', 'Last-Modified' and 'Etag' headers. When running attr('src', newimage) with jQuery, the initiated request neither checks the browser cache, nor sends the request headers 'If-Modified-Since' and 'If-None-Match' :(
Does anybody know how to tell jQuery to check the browser cache before sending a request to the server?
BTW, I am using jQuery 1.7.1
jQuery is ignorant to the browser's cache. You won't be able to "tell jQuery to check the browser cache" because JavaScript has no knowledge of the browser's cache.
If it's critical that the images not come from the cache, and you find that they're always being reloaded, maybe you should just include all of the images- and when it's time to show a specific image, hide all of the images and show only the one whose src matches your desired src.