Solved

How to refresh image cache?

Posted on 1998-09-04
10
390 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
Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

 
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
 

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

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Foreword (July, 2015) Since I first wrote this article, years ago, a great many more people have begun using the internet.  They are coming online from every part of the globe, learning, reading, shopping and spending money at an ever-increasing ra…
"In order to have an organized way for empathy mapping, we rely on a psychological model and trying to model it in a simple way, so we will split the board to three section for each persona and a scenario and try to see what those personas would Do,…
This tutorial demonstrates how to identify and create boundary or building outlines in Google Maps. In this example, I outline the boundaries of an enclosed skatepark within a community park.  Login to your Google Account, then  Google for "Google M…
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

813 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

10 Experts available now in Live!

Get 1:1 Help Now