Pixy方法受到IE的cache bug影响会闪烁。其实并没有说清楚这个问题,但其实该bug是有条件的,即IE的cache设置为Every visit to the page,而不是默认的Automatically。基本上,只有开发者才会把cache设置为每次访问检查更新,所以这个bug其实不会影响真正的用户 (根据在winxpsp2的ie6下测试,虽然可能仍然调用了一次网络存取的api,但是并没有发生实际的请求,症状就是鼠标有极短时间的抖动,但是图像 不会闪烁)。此外有人发现了一个未公开的方法来让IE对背景图进行缓存: document.execCommand("BackgroundImageCache",false,true) 用这种方法甚至避免了api调用,貌似是直接缓存在IE内存中。
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):
Much simpler but makes me wonder why this is not the default setting?
/** * 相关回复 * by Nicholas C. Zakas @2007-02-26 */ 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".