dcsimg

How can I force the web browser to cache my images?

Salman Khan

In JavaScript, do

var image1 = new Image();
image1.src = "xyz.gif";
And then use image1.src wherever you were using the xyz.gif

This will cache the image.

See also http://www.jguru.com/faq/view.jsp?EID=377

[Note: there seems to be a bug in IE 5.5 preventing this from working. See the forum thread for details. -A]