[thelist] HTTP Header Resource

Warden, Matt mwarden at odyssey-design.com
Fri Jan 5 23:18:12 CST 2001


> I had this problem a while ago and tried the method you mentioned but
> could achieve any success. In the end the way I got round this was using
> PHP to place a number on the end of the url like so ...
>
> Generate a number
> <? $randid = "time()"; ?>
>
> Call the image like so...
> <? echo "<img src=../images/$picture_name?$randid>"; ?>

It's a good idea, BUT, I'd have to do this with JavaScript. If I could just
write HTML, I wouldn't be having a problem. The problem comes in because i'm
only feeding image bytes back to JavaScript as so:

var img = new Image();
img.src = "myphpscript.php?foo=bar";

And then I'm swapping the image with an existing one on the page. This
explains why I can't do the following:

> a simple solution that's worked for me is to force a hard reload with
> Javascript.
>
> location.reload(true);
> will force a server refresh that bypasses cached content.

because the whole point here is to avoid a refresh just to display a new
image. And then Jeff offered:

> lemme guess - webcam.

Nope.

> there's only two ways - meta tags to force a refresh of the entire page or
> making the path to the image look different to the browser every time.  the
> second is the preferred method.
>
> psuedo-code - translate to your language of choice.
>
> random_num = current time stamp in milliseconds.
>
> <img src="image.gif?somevar=[random_num]">

I think the only way I could do this is to use JavaScript to do something like
the above. I'd probably expand it to:

img.src = "myphpscript.php?" + randomNum1 + "=" + randomNum2;

I was really hoping I could just add an expires HTTP header when I'm feeding
the image bytes to tell the browser not to cache it. Not gonna happen, I
guess.

Then, Big Oliver wrote:

> HTTP-EQUIV literally means "treat this meta value as if it were an HTTP
> header".

Yup. I don't think you can say that all HTTP-EQUIV METAs are HTTP headers and
vice versa, can you?

> also, a word about the random-number solution.  my advice is to set the
> pragma HTTP header too regardless.  this is because the random-number
> solution is no use if some other site wants to reference your cam's
> image.  (this can actually be an advantage or disadvantage, depending on
> whether you want other people referencing your image).

Neither, since it's not a webcam.   ;-)


--
mattwarden
mattwarden.com





More information about the thelist mailing list