Link to home
Start Free TrialLog in
Avatar of faur
faur

asked on

Non caching image

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.
Avatar of Otta
Otta

It cannot be done.

The user's browser controls the caching,
and you cannot override it.
Avatar of faur

ASKER

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.
I think Otta is right, unless you can explicitly set the content expiration via the HTTP header that gets the image.
ASKER CERTIFIED SOLUTION
Avatar of Otta
Otta

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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.
> ... 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".

Yes, it's actually a recent bug, and they are already aware of it.
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".
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.
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.
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.
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.
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?