How to refresh image cache?

How can you require an image to be refreshed when a page is loaded?  I have a gif that is updated periodically but has the same filename.  I understand that images are cached separately so Reload won't cause the new gif to load.
jmallenAsked:
Who is Participating?
 
sybeConnect With a Mentor Commented:
You have to change your HTML in the way MasseyM suggested. I am not sure why you have rejected his answer.

If your HTML is generated by ASP, then do something like:

<img scr="yourimage.gif?<%=Server.URLEncode(Now())%>">

CGI's should have similar functions.

If your page is plain HTML, then you have to use javascript (and it won't work with browser without javascript enabled:

<script>
var Now = new Date();
document.write("<img src='yourimage.gif?" + escape(Now) + "'");
</script>

Both will fool the browser, telling it's a different image everytime the page is (re)loaded, and will prevent the browser using the cached image.

0
 
jmallenAuthor Commented:
Adjusted points to 100
0
 
MasseyMCommented:
If the image created using CGI or something like that? if it is, add the date to the end of the filename (image080598.gif) this will then load everytime...


0
Cloud Class® Course: CompTIA Cloud+

The CompTIA Cloud+ Basic training course will teach you about cloud concepts and models, data storage, networking, and network infrastructure.

 
kamyanlaiCommented:
What browser do you use ?
This is important to refreshing the cache.
0
 
vlad_impalaCommented:
You could try using some META tags in your page to prevent caching of the page
<META HTTP-EQUIV="Pragma" CONTENT="no-cache">  should stop the page being cached.
Alternatively you could put an expiry date on the page such as
<META HTTP-EQUIV="expires" CONTENT="Wed, 26 Feb 1997 08:21:57 GMT">

I think there may be some problems with Internet Explorer ignoring META tags so thius may not work for IE.

Vlad.
0
 
ckayterCommented:
IE does not ignore Meta tags. You shouldn't have any problems using a nocache tag.

Colleen

0
 
jmallenAuthor Commented:
Not using cgi to create the image and the filename needs to remain the same.  Have already tried META tags (Expires and Pragma) which work for text but not for images.  The solution needs to work for *most* browsers.  Right now I'm attacking it with server-side javascript, but wanted to know if there was a more simple/elegant solution.
0
 
Patricia080698Commented:
The best answer that I can give you is that you disable caching within your browser. for example, in netscape, (preferences) there is an option that lets you specify the size of your cache, if you disable it (put them both to 0 kb) that you will have no problem. Every time your pages load so do your images. It does not insert it in the cache directory. That should work. Best of luck.
0
 
wsanchezCommented:
You could check out
   http://www.experts-exchange.com/topics/comp/www/images/Q.10076409

It's not exactly the same problem as yours but I think it is related to your question.
0
 
jmallenAuthor Commented:
This needs to be addressed on the server side (Netscape Enterprise 3).  I can't require everyone looking at this page to disable or empty their cache!  The problem arises because I am allowing a user permission to change the contents of an image file (in a directory with ACL set up for her permission), but *not* the contents of the HTML file (in a restricted directory) that links to it.  When the image file has been updated, a simple Reload will not cause the image to be reloaded as well.  The image filename must remain the same, because the HTML file linking to it will not be changed.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.