Re: Disable all caching
| From: | Richard Lynch | Date: | Tue, 10 Oct 2006 17:14:52 +0000 |
| Subject: | Re: Disable all caching | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-242911@lists.php.net to get a copy of this message | ||
On Tue, October 10, 2006 10:17 am, Benjamin Adams wrote:
> I have a php (ver 4.x) script that is being cached.
> I have placed:
> <META HTTP-EQUIV="CACHE-CONTROL" CONTENT="NO-CACHE">
> but the page is still being cached. I'm not sure if its apache or
> the php. How can I disable all caching?
> is there something I can set in php.ini?
All the headers and all the META tags in the world won't get EVERY
browser and EVERY caching / proxy server (AOHell) to stop caching.
If you really truly absolutely MUST have no caching at all, generate
random/unique URLs for your content.
<img src="/images/phpscript/nocache=<?php echo
mt_rand()?>/whatever.jpg" />
phpscript can be ForceType'd to readfile whatever.jpg (or to
fopen/fread/echo if your JPGs are large) and the nocache will
guarantee the browser won't cache it.
More precisely, the browser WILL cache it, but you send the browser a
new URL every time, so it renders the cached item useless.
Maybe if the browser-makers actually honored the no-cache headers they
keep making up out of thin air, I would feel bad about wasting their
cache like this. But they don't, so I don't.
You need the .jpg at the end for IE to do the right thing.
--
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some starving artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?