Re: Is it possible to stop an image from being cached?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, July 26, 2007 4:56 pm, Dan wrote:
> Is there any tactic short of changing the name constantly of the image
> to
> avoid browser caching of an image?

You can try to use all the zillion header calls people will send you.

Somewhere out there is a really stupid browser that will insist on
caching it.

src="somebody.jpg?<?php echo uniqid()?>" will make it very difficult
for any halfway-decent browser to cache.

However, that can lead to some issues when the URL of the image is
embedded elsewhere, as some folks will strip off the GET arg on the
assumption that it's invalid for a JPEG.

Embedding the random bit so that it LOOKS like a directory, but isn't,
will avoid that problem.

I blogged about how to do this kind of thing (in another context) over
here:
http://richardlynch.blogspot.com/2006/06/php-downloads-content-disposition.html

There are shorter / better explanations out there, but I don't know
where without Googling, and you know how to Google, right?

-- 
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux