Notice: This website is an unofficial Microsoft Knowledge Base (hereinafter KB) archive and is intended to provide a reliable access to deleted content from Microsoft KB. All KB articles are owned by Microsoft Corporation. Read full disclaimer for more details.

PRB: Internet Explorer Cache Is Not Used When You Run innerHTML Code to Insert the Same Image Multiple Times

View products that this article applies to.


When you run Internet Explorer, the Internet Explorer cache is not used as you expect when you run innerHTML code to insert the same image multiple times. Notice the following code samples:
myDiv1.innerHTML = "<IMG SRC='image.gif'>"
myDiv2.innerHTML = "<IMG SRC='image.gif'>"
The preceding code results in sending two GET requests to retrieve the Image.gif file in Internet Explorer 6.0. Three GET requests are sent to retrieve the Image.gif file in Internet Explorer 5.5. Your expectation is that the Web server would be hit only one time.

↑ Back to the top


To work around this problem, use one or both of the following methods:
  • Preload the image in a DIV element with the display:none attribute:
    <DIV style='display:none'><IMG SRC='image.gif'></DIV>
  • Create a brief time-delay so that Internet Explorer has enough time to verify whether the image is in the cache, and then call the innerHTML property.

↑ Back to the top


This behavior is by design.

↑ Back to the top


Retired KB Content Disclaimer
This article was written about products for which Microsoft no longer offers support. Therefore, this article is offered "as is" and will no longer be updated.

↑ Back to the top

Keywords: KB319546, kbprb

↑ Back to the top

Article Info
Article ID : 319546
Revision : 4
Created on : 10/13/2003
Published on : 10/13/2003
Exists online : False
Views : 347