Solved

Making sure a image is loaded everytime.

Posted on 1998-08-11
8
193 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Don't Cry: How Liquid Web is Ensuring Security

WannaCry is just the start. Read how Liquid Web is protecting itself and its customers against new threats.

 
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

Are You Using the Best Web Development Editor?

The worlds of web hosting and web development are constantly evolving. Every year we see design trends change, coding standards adapt and new frameworks/CMS created. With such a quick pace of change it’s easy to get lost trying to keep up.

See if your editor made the list.

Question has a verified solution.

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

Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
This article discusses four methods for overlaying images in a container on a web page
In this tutorial viewers will learn how to embed Flash content in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: "<!DOCTYPE html>": Use the <object> tag to embed Flash content.: To specify that the object is Flash content, d…
The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.

623 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