Solved

Making sure a image is loaded everytime.

Posted on 1998-08-11
8
190 Views
Last Modified: 2010-04-09
Hi,
    How do I make sure an image is not loaded from the cache but rather from the site everytime.  They way I can think of doing this is not putting the image in the cache in the first place, but how do I do this?
0
Comment
Question by:cide
  • 3
  • 2
  • 2
  • +1
8 Comments
 
LVL 10

Expert Comment

by:MasseyM
ID: 1845198
You can set the expiration date for the page... Using ASP, you would simply use:

<% response.expires = Now()%> This will keep the picture out of the cache... I am not sure how to do it outside of ASP though... So, maybe someone else knows how to pass an HTML header to a browser.


0
 

Author Comment

by:cide
ID: 1845199
What's ASP?
0
 
LVL 2

Expert Comment

by:Quixote
ID: 1845200
Even if you could code your page in ASP, this wouldn't do it.  The browser would understand that the page expires from cache immediately, but the stuff *in* the page wouldn't expire.

Otherwise, I would suggest using the plain-Jane HTML tag in the <head>

<meta http-equiv="Expires" content="January 1, 1970 00:00:00 GMT">

But I don't think that'll work.
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 28

Expert Comment

by:sybe
ID: 1845201
Use javascript to give the picture a time dependent querystring:

<script>
now = new Date();
document.write("<img src='yourimage.jpg?"+escape(now)+"' width=50 height=50 border=0>");
</script>

This way the browser will it's a different image every time and not get it from the cache.


By the way ASP is Active Server Pages, it has to do with scripting. It is like javascript (or vbscript), but the script is executed at the server. The browser just sees HTML.

0
 
LVL 2

Expert Comment

by:Quixote
ID: 1845202
Sybe's solution works.  I've used it before.  I didn't think of it because I had such a bad experience with the technique, one you will want to avoid:

Using Sybe's technique, the same image is downloaded and put into cache each time the page is rendered.  It is never called from cache, which is what you want.  However, in a single browsing session, if this page is rendered often, then this image can rapidly choke the cache.  We used this technique in an ad-frame that refreshed every 20 seconds -- which meant that every 20 seconds a new cache-entry was being made.  Choked us up big time if the user hung out for an hour.

In general, go with his technique if you only are goign to load the page less than 50 times or so; less if the image is big.
0
 

Author Comment

by:cide
ID: 1845203
The problem is it's actually a cgi program so I'll have to modify my cgi code.  That's no biggy though.  I was thinking of the same thing you guys were except use a random number.
0
 
LVL 28

Accepted Solution

by:
sybe earned 50 total points
ID: 1845204
When your output is generated by cgi, then you don't even need javascript to do it, you can get the time in your cgi script and just write it in the querystring.

Random numbers will work too of course, but you have to randomize them from time anyway, so why just not use time rightaway.
0
 

Author Comment

by:cide
ID: 1845205
I mean it loads cgi.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Mobile apps - web/native or hybrid? 1 67
Fix Form size HTML 16 30
Send email using HTML and PHP in separate file 5 39
Link Anchor Not working 9 47
This is a PowerShell web interface I use to manage some task as a network administrator. Clicking an action button on the left frame will display a form in the middle frame to input some data in textboxes, process this data in PowerShell and display…
Not sure what the best email signature size is? Are you worried about email signature image size? Follow this best practice guide.
The viewer will learn the benefit of using external CSS files and the relationship between class and ID selectors. Create your external css file by saving it as style.css then set up your style tags: (CODE) Reference the nav tag and set your prop…
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

749 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