Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Making sure a image is loaded everytime.

Posted on 1998-08-11
8
Medium Priority
?
198 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
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 200 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

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

Question has a verified solution.

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

This article describes how to create custom column layout styles for Bootstrap. The article uses 5 columns to illustrate the concept, but the principle can be extended to any number of columns.
Originally, this post was published on Monitis Blog, you can check it here . Websites are getting bigger and more complicated by the day. Video, images and custom fonts are all great for showcasing your product or service. But the price to pay in…
In this Micro Tutorial viewers will learn how to create navigation buttons that change on rollover, using CSS (Continuation of the CSS Image Sprite tutorial) Create a parent ID for all the list items       - Specify position: absolute and display: block…
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

963 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