IE6 Requests CSS Background Image Every Time!

Discussion in 'Javascript' started by vunet.us@gmail.com, May 7, 2007.

  1. Guest

    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?
     
    , May 7, 2007
    #1
    1. Advertising

  2. Matt Kruse Guest

    On May 7, 8:59 am, wrote:
    > 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
     
    Matt Kruse, May 7, 2007
    #2
    1. Advertising

  3. Guest

    On May 7, 10:08 am, Matt Kruse <> wrote:
    > On May 7, 8:59 am, wrote:
    >
    > > 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 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.
     
    , May 7, 2007
    #3
  4. Guest

    On May 7, 10:38 am, wrote:
    > On May 7, 10:08 am, Matt Kruse <> wrote:
    >
    >
    >
    > > On May 7, 8:59 am, wrote:

    >
    > > > 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 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.


    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?
     
    , May 7, 2007
    #4
  5. Kris Zyp Guest

    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

    On May 7, 7:47 am, wrote:
    > On May 7, 10:38 am, wrote:
    >
    >
    >
    >
    >
    > > On May 7, 10:08 am, Matt Kruse <> wrote:

    >
    > > > On May 7, 8:59 am, wrote:

    >
    > > > > 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 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.

    >
    > 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?- Hide quoted text -
    >
    > - Show quoted text -
     
    Kris Zyp, May 8, 2007
    #5
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Marianne
    Replies:
    5
    Views:
    642
    brucie
    Oct 17, 2004
  2. guest
    Replies:
    0
    Views:
    340
    guest
    Feb 4, 2007
  3. guest
    Replies:
    4
    Views:
    453
    Chris F.A. Johnson
    Feb 5, 2007
  4. =?Utf-8?B?SXJ3YW5zeWFo?=
    Replies:
    4
    Views:
    2,480
    =?Utf-8?B?SXJ3YW5zeWFo?=
    Oct 30, 2007
  5. guest
    Replies:
    0
    Views:
    113
    guest
    Feb 4, 2007
Loading...

Share This Page