Solved

How to refresh image cache?

Posted on 1998-09-04
10
384 Views
Last Modified: 2013-12-25
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.
0
Comment
Question by:jmallen
10 Comments
 

Author Comment

by:jmallen
ID: 1865669
Adjusted points to 100
0
 
LVL 10

Expert Comment

by:MasseyM
ID: 1865670
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
 

Expert Comment

by:kamyanlai
ID: 1865671
What browser do you use ?
This is important to refreshing the cache.
0
 
LVL 3

Expert Comment

by:vlad_impala
ID: 1865672
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
 
LVL 6

Expert Comment

by:ckayter
ID: 1865673
IE does not ignore Meta tags. You shouldn't have any problems using a nocache tag.

Colleen

0
Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

 

Author Comment

by:jmallen
ID: 1865674
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
 
LVL 1

Expert Comment

by:Patricia080698
ID: 1865675
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
 

Expert Comment

by:wsanchez
ID: 1865676
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
 

Author Comment

by:jmallen
ID: 1865677
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
 
LVL 28

Accepted Solution

by:
sybe earned 100 total points
ID: 1865679
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

Featured Post

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Both Easy and Powerful How easy is PHP? http://lmgtfy.com?q=how+easy+is+php (http://lmgtfy.com?q=how+easy+is+php)  Very easy.  It has been described as "a programming language even my grandmother can use." How powerful is PHP?  http://en.wikiped…
Although it can be difficult to imagine, someday your child will have a career of his or her own. He or she will likely start a family, buy a home and start having their own children. So, while being a kid is still extremely important, it’s also …
This video teaches users how to migrate an existing Wordpress website to a new domain.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now