IE Background Cache Fix
A while back a lot of people where covering how to work around the bug that IE always reloads background images from the server, leading to your UI flickering. Dean wrote one and lots of others wrote the same thing. Today, I saw this simple workaround (from a fellow Googler who worked at Microsoft before):
document.execCommand("BackgroundImageCache", false, true)
Much simpler but makes me wonder why this is not the default setting?
February 26th, 2007 at 14:29
I’ve actually wondered about this “bug” for a while. I’m sure somewhere along the line this decision was made for a logical reason…maybe they didn’t anticipate how much background images would be used, or maybe they thought there was some use case under which it would be desirable not to cache the background image. I’m generally not big on overriding things that seem to be design decisions (which this seems to be). I’ve never really thought this was a “bug”…bugs don’t usually have switches that say “turn off bug”.
February 26th, 2007 at 16:07
Brilliant :-D, though it has been mentioned before:
http://www.mister-pixel.com/#Content__state=is_that_simple
@Nicholas:
I agree - it’s not a bug.
It’s yet another Microsoft conspiracy ;-), revealed here:
http://www.bazon.net/mishoo/articles.epl?art_id=958#gen5
February 26th, 2007 at 18:38
It is fixed in IE7 by the way so I would definitely call this a bug. A bug by design
Thomas: I saw that this had been mentioned before but since I didn’t know about it before I thought I would spread the word.
February 27th, 2007 at 6:39
[...] IE Background Cache Fix on erik’s weblog [...]
March 20th, 2007 at 5:51
This is a helpful tip.
I have noticed only one problem with this, and it seems to occur in IE6 on Windows Server 2003 platforms. The execCommand fails and throws an “Invalid Argument” error.
A try/catch around the command seems to do the trick.
March 20th, 2007 at 23:24
I am a new to Programming and held up with this issue….. I got an image as a background image for my header.(header is 10% of my screen). when ever the page refreshes and gets time to load, i see that the image missing giving the user a feel that it is not there.Once the page is loaded completely it appears again. I tried the above solution by giving that code in my onload function. But it didnt help. can any one help me to solve this?
March 22nd, 2007 at 20:38
Yeah, at Google we use a try catch around it for exactly that reason.
July 11th, 2007 at 2:13
Having the same issue with a map on aspx page, with update panel located on the same page.
every time the update panel being updated the map flickers,
does anyone know a way to prevent this from happening?
I am using IE7
November 15th, 2007 at 9:27
It does not work, if you change css dinamicly (menu for example).
To prevent this, add any tag with your style and set it invisible.
imho, if there is no element uses any style, IE will download background image every time element with this style appears.