IE6 Requests CSS Background Image Every Time!

V

vunet.us

Hi,
I found a bug in IE6, though it is known already. If I have a CSS
background property set to some image, such as
background:url(myimg.gif);, and I apply this property to some html
element, say DIV, and refresh DIV every 10 seconds, background image
is reguested every 10 seconds for IE6, too.

The fix which I found did not fix the problem:
try {
document.execCommand("BackgroundImageCache", false, true);
} catch(err) {}

Relative info:
http://www.mister-pixel.com/#Content__state=is_that_simple
http://dean.edwards.name/my/flicker.html
http://www.fivesevensix.com/studies/ie6flicker/

What's the known workaround?
 
M

Matt Kruse

The fix which I found did not fix the problem:
try {
document.execCommand("BackgroundImageCache", false, true);

} catch(err) {}
What's the known workaround?

It seems to work for me. I have this in many of my site js files:

// Turn on background image caching in IE
// --------------------------------------
/*@cc_on
if (document && document.execCommand) {
try { document.execCommand("BackgroundImageCache",false,true); }
catch (e) { }
}
@*/

Matt Kruse
http://www.JavascriptToolbox.com
 
V

vunet.us

It seems to work for me. I have this in many of my site js files:

// Turn on background image caching in IE
// --------------------------------------
/*@cc_on
if (document && document.execCommand) {
try { document.execCommand("BackgroundImageCache",false,true); }
catch (e) { }}

@*/

Matt Krusehttp://www.JavascriptToolbox.com

Hmmm... Maybe it works, but my access.log file in Tomcat shows these
images are requested every time. How do you know if it works for you?
Thanks.
 
V

vunet.us

Hmmm... Maybe it works, but my access.log file in Tomcat shows these
images are requested every time. How do you know if it works for you?
Thanks.

Additional word. It solved the problem (with JS or server
configuration) by sending HTTP 304 (not modified) instead of earlier
200 (request ok). But I do not to see those requests at all. How
possible is it?
 
K

Kris Zyp

The most effective way to solve this problem (and improve the
performance of your application at the same time) is to apply caching
header directives. All images should have a caching header indicating
when the image should expire from the cache. With this header IE will
cache the image and not continually make requests over and over.
Tomcat does not have the ability to do this out of the box. I
actually just finished a release of a little Tomcat/J2EE app server
plugin (a filter) that makes this very easy to do. You can take a look
and download Resource Accelerate at http://www.xucia.com/#Resource Accelerate.
This should apply caching headers for you and fix your multiple
request problem.
Kris
www.xucia.com
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,049
Latest member
Allen00Reed

Latest Threads

Top