Solved

Non caching image

Posted on 1998-04-22
13
205 Views
Last Modified: 2013-12-25
I'm trying to make a HTML page with an image that won't be cached. I need only need the image to be non-cached, not the entire page.

Thanks.
0
Comment
Question by:faur
13 Comments
 
LVL 12

Expert Comment

by:Otta
ID: 1853965
It cannot be done.

The user's browser controls the caching,
and you cannot override it.
0
 

Author Comment

by:faur
ID: 1853966
Otta, if your answer is "cannot be done", please comment the question, do not answer it.
That way, other people (who might have other suggestions than "cannit be done") can answer it.

Thanks anyway.
0
 
LVL 3

Expert Comment

by:percyn
ID: 1853967
I think Otta is right, unless you can explicitly set the content expiration via the HTTP header that gets the image.
0
 
LVL 12

Accepted Solution

by:
Otta earned 100 total points
ID: 1853968
It can't be done.  That is the "correct" answer,
and the correct answer gets the "points".
0
 
LVL 5

Expert Comment

by:julio011597
ID: 1853969
An image outputted from a CGI is NOT cached, AFAIK.
Graphic counters wouldn't work otherwise:

<IMG SRC="counter.cgi">

Maybe this is a more appropriate answer to "i'm trying to make an HTML page with an image that won't be cached."

BTW, yes, this has to do with HTTP headers sent back.

faur, please keep in mind that, if you are going to both reject an expert's answer and add a comment AT THE SAME TIME, nobody but that expert will be notified of it... you should first reject, then add the comment - i.e. two separate steps.
0
 
LVL 12

Expert Comment

by:Otta
ID: 1853970
> ... please keep in mind that,
> if you are going to both reject an expert's answer
> and add a comment AT THE SAME TIME, nobody but
> that expert will be notified of it...
> you should first reject, then add the comment
> - i.e. two separate steps.

This sounds like a "bug" in E-E, rather than a "feature".
Are you sure?  If so, please post this deficiency
as either a "bug-report" or a "request for enhancement".

0
3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

 
LVL 5

Expert Comment

by:julio011597
ID: 1853971
Yes, it's actually a recent bug, and they are already aware of it.
0
 
LVL 12

Expert Comment

by:Otta
ID: 1853972
Maybe, there is a way, if you're sure that the user's
browser has JavaScript enabled.

For an example, see:

http://WWW.IntrigueMe.com/english/

which displays a "count-down" (DD:HH:MM)
until the contest ends.

Of course, if the user's browser does NOT
support JavaScript, or if the user has
disabled it, or if the user has disabled
the auto-loading of images,
then the answer still is "it cannot be done".
0
 
LVL 5

Expert Comment

by:julio011597
ID: 1853973
In that case, Javascript just loads a bunch of Images to show the right digits; the images themselves will be loaded from cache if you've already seen them once - at least on Netscape, since someone told IE overrides cache in case of Javascript image loading, but i've not verified it and would not trust it very much.
0
 
LVL 12

Expert Comment

by:Otta
ID: 1853974
Yes, JULIO, the images *could* be loaded from the cache.
However, since the JavaScript program is still "running",
the screen "updates" every minute.
So, in the string 'DD:HH:MM', certainly the image
for the 'DD' will be retrieved from cache,
but the newly-updated 'MM' value will need to be
downloaded across the network.
0
 
LVL 5

Expert Comment

by:julio011597
ID: 1853975
Sorry Otta, here is what i meant:

they have ten images, one for each digit; there names are d_ 0s.gif, d_1s.gif, d_2s.gif, ..., d_9s.gif.
Their Javascript code just loads the proper images on the proper time, BUT, if you've already seen - say - d_0s.gif, then you'll keep getting it from cache each time it is redisplayed, even in 'MM', even while the script is "running".

There's no way in Javascript to prevent caching.

Now, if you don't mind, i'd suggest we give this thread back to its owner.
0
 
LVL 3

Expert Comment

by:bigelos
ID: 1853976
faur,
Otta is right.  Can't be done.  Even if you set the page to expire early, it will still be cached--it just gets updated everytime the page is loaded.

Maybe if you told us what you were trying to accomplish, we could help you better by providing an alternative method.
0
 
LVL 12

Expert Comment

by:Otta
ID: 1853977
OTTA wrote:
> So, in the string 'DD:HH:MM', certainly the image
> for the 'DD' will be retrieved from cache,
> but the newly-updated 'MM' value will need to be
> downloaded across the network.

JULIO wrote:
> they have ten images, one for each digit;
> there names are d_ 0s.gif, d_1s.gif, d_2s.gif, ..., d_9s.gif.
> Their Javascript code just loads the proper images
> on the proper time,
> BUT, if you've already seen - say - d_0s.gif,
> then you'll keep getting it from cache
> each time it is redisplayed,
> even in 'MM', even while the script is "running".

I think that we have a "heated-agreement".  :-)
There's no difference in the two statements.

However, "extend" the concept beyond the actual code
used on the 'INTRIGUEME' web-site, and conceptualize
the "technique" used by the Java code.  This "trick"
causes images to be "pulled" from the web-server
on an "just-in-time" basis.

Of course, once the browser has retrieved any image,
it must be "cached", because the user can either
"resize" or "move" or "scroll" the browser-window, at any time.
Imagine the "processing-overheads" if such a user-action
were to force the web-browser software to download
a "fresh" copy of the text & images!  Prohibitive, correct?

0

Featured Post

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

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

"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,…
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 tutorial walks through the best practices in adding a local business to Google Maps including how to properly search for duplicates, marker placement, and inputing business details. Login to your Google Account, then search for "Google Mapmaker…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

914 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

18 Experts available now in Live!

Get 1:1 Help Now