Friday, September 29, 2006

A note on the BackgroundImageCache command identifier used on IE6 "standalone"

If you are using the multiple IEs in Windows techinque described here, please note that the standalone IE6 does not contain the SP1 so the fix won't work. Thanks to 'Big John' for the tip.

Monday, September 25, 2006

A forensic analysis of the IE6 BackgroundImageCache command identifier

The document.execCommand("BackgroundImageCache", false, true) command seems to do at least what it's name suggests: cache the background images.

Let's see the visible effects of this command.

Step 1: "Is it modified YET?"

IE would "normally" check with your web server for newer versions of the css background images prior to applyng a css rule, no matter what is the value of the cache option. Make it "Every visit to the page.", "Automatically" or "Never", it does not matter, IE wants to know anyway.

Check this with Fiddler. Open the following page in IE: http://www.positioniseverything.net/css-dropdowns.html

See the hordes of requests for a tinny image, all getting the "304 Not Modified" response header. In it's greed to make all these requests, IE actually gets to abort some of them just to make room for others :))

Here's how to fix this insanity: run this bookmarklet inside the IE Addres Bar:

javascript:void(document.execCommand("BackgroundImageCache",false,true))

Look mom, there's no more traffic! Your poor ol' web server can rest now!

Now, let's move on for some more atrocities.

Step 2: "Where's my memory?"

Check the IE Memory Usage: open the above page in a clean instance of IE.

Play with the menu for a while, then check the Internet Explorer Memory Usage in task manager. Continue to move the mouse over the menu while keeping an eye on the "Mem Usage".

On my computer, IE memory heavily bounces between 21MB and 27MB and the menu is slow.

Now apply the patch on the page by running the following bookmarklet inside the IE address bar:

javascript:void(document.execCommand("BackgroundImageCache",false,true))

Guess what! The "Mem Usage" won't shake like this guy anymore and the menu will move much smother. Pages using extensive css background images run a lot smoother with the fix applied.

Step 3: "Move your platans, you lazy, good for nothing hard disk!"

So, it seems IE cache the bg images in memory, with no access to hard disk.

If you take a look at IE using the File Monitor from SysInternals you'll get the picture.

Close all IE instances, open IE, start File Monitor, filter events by process name iexplore, go to the above URL and start moving the mouse over the menus. You'll get something like 360 disk access for just going with the mouse over one menu item. Now apply the patch using the bookmarklet and continue moving the mouse over the menus. You'll see what I mean.

I can't tell at this moment if this fix would cause memory leaks. I don't know yet what's the catch, if there is any.

But it does a pretty good job for me.