setting the src attribute using script and caching images

C

cosmic foo

I have noticed that when you set the src attribute of an img via script,
(instead of hard-coding in the img tag), although it caches the images,
if you leave the site and return, the browser has to re-cache the images.
Is that just the way it is, or is there a way to not lose the cache?
Thanks.
 
A

ASM

cosmic said:
I have noticed that when you set the src attribute of an img via script,
(instead of hard-coding in the img tag), although it caches the images,
if you leave the site and return, the browser has to re-cache the images.

no, I don't think it does re and re and re-cache same image ou same src
onload it always verify if image (even an image.src) is in its cache
just by scripting you realy ensure it does it and get a local source
then you can re-use src instead of url
-> shorter code and image from cache without mistake
(no need to call server (send requests existing img? date? and so one) )
 
C

cosmic foo

ASM said:
images.

no, I don't think it does re and re and re-cache same image ou same src
onload it always verify if image (even an image.src) is in its cache
just by scripting you realy ensure it does it and get a local source
then you can re-use src instead of url
-> shorter code and image from cache without mistake
(no need to call server (send requests existing img? date? and so one) )

what?
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,766
Messages
2,569,569
Members
45,042
Latest member
icassiem

Latest Threads

Top