I have a variety of image sets that I'm displaying on a web page (say 50 images per set). A user may select a set to display from a list, which is loaded via a jQuery ajax call to remove the old img tags and add the new ones.
What I'm seeing is that all of the requests for the first batch of stale images still get pulled from the server, thereby delaying the load of new images and killing the UX. So my question is: is it possible to purge the requests from the browser for the first set of img's that no longer exist in the DOM? Is this not automatic?
Here is a sample jQuery snippet of the process:
updateImages = function(imageSetId) {
// clear existing IMG set
$("#imagesDiv").empty();
$.post(
"/GetImagesInSet",
{ imageSetId: imageSetId },
function(data) {
// add in new IMG set
$("#imagesDiv").html(data);
},
"html"
);
};
My expectation was that the call to $().empty() would prevent all the pending images that live in it to be removed from the request queue. I'll take alternative suggestions if this is a poor design!