new image makes http request even though cached?
Posted
by joshs
on Stack Overflow
See other posts from Stack Overflow
or by joshs
Published on 2010-05-13T05:21:40Z
Indexed on
2010/05/13
5:24 UTC
Read the original article
Hit count: 239
I have a javascript slide show that creates the next slide dynamically and then moves it into view. Since the images are actually sprites, the src is transparent.png and the actual image is mapped via background:url(
.. in css.
Everytime (well, most of the time) the script creates a new Element
, Firefox makes an http request for transparent.png. I have a far-future expires header, and Firefox is respecting all other files' expiries.
Is there a way to avoid these unnecessary requests. Even though the server is returning 304 unmodified
responses, it would be nice if Firefox would respect the expiries on dynamically created images.
I suspect that if I injected a simple string instead of using new Element, this might solve the problem, but I use some methods on Prototypes extended Element
object, so I would like to avoid a bunch of html strings in my js file.
This is a nit-picky question, but I'm working on front-end optimization now, so I thought I would address it.
Thanks.
© Stack Overflow or respective owner