[thelist] image cache/no-cache

Richard Bennett richard.bennett at skynet.be
Tue Aug 21 05:07:35 CDT 2001


> If I have someone re-upload an image and save it with the same name on the
> server, is there any clever way to force the browser to re-load that image
> only?


Hi, there is a nice little trick to make sure the image shown doesn't come
from cache, it uses javascript:

<tip type=images>
Need to be sure an image is not loaded from cache? try this:

<html><head><script language="Javascript">

  document.write('http://www.cnn.com/images/logo.gif?'+new Date().getTime())
  document.write('<br /><img src="http://www.cnn.com/images/logo.gif?'+new
Date().getTime()+'" />')

</script></head><body></body></html>

It adds a query-string to the imagename, so the image-name is always
different.
You can also update an existing image's source instead of using
document.write, using the browsers DOM.

</tip>

Richard.







More information about the thelist mailing list