Re: New image already cached.

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

 



Browsers are not at all reliable about caching (or not) anything other
than HTML text in terms of HTTP Headers.

Don't waste your time looking for a set of HTTP Headers that will work.

I can guarantee *SOME* user out there will have a browser that will do
the "Wrong Thing" for any set of headers you can find.

And, Murphy's Law, your boss/client will use *THAT* browser, and love it.

The easiest answer is to add /copyright/ into the URL for the one that
needs the copyright notice merged in.

If however, you want to be sure the browser doesn't cache the image,
because it is dynamic, just add some randomness to the URL.

Technically, that means the browser WILL cache it, but you'll never
use the same URL twice, so you won't really care.

You're also better off embedding the parameters in the URL so that it
"looks like" a directory to the browser:

http://example.com/actual_script/57823642346963/copyright/whatever.png

The PHP scritp is actual_script.

You can use .htaccess and ForceType to make Apache run it.

$_SERVER['PATH_INFO'] will have all the parameters you need.

I think all the browsers get it right with ?x=5&y=7 for Images, but
some ersions of IE will screw up when you try to apply the same
techniques to PDFs and FDFs.

The embedded parameters pretty much give the browser NO opportunity to
screw up.

Remember Rule #1.
Never trust the browser.
Or the user of the browser.

On Tue, April 18, 2006 5:47 pm, tedd wrote:
> Hi gang:
>
> I wrote a program that presents a bunch of thumbnails to the users.
> When the user wants to view a larger version of one of the
> thumbnails, s/he simply clicks the thumbnail and another page is
> displayed with the larger image -- nothing new there.
>
> However, considering that the larger image is copyrighted, the client
> wanted a copyright printed across the image, but not on the thumbnail
> (too small to worry about and it distracted from the small image).
>
> So, my code takes two images, merges them (i.e., the large version
> with a copyright) and then presents the new image to the browser via
> a link. It sounded good and works in Safari and FireFox.
>
> Unfortunately, not all browsers treat an image link in the same
> manner. For example, Safari and FireFox treats the link
> "/images/merged.png" as a new image every time. Unfortunately, Opera
> and some other browsers cache the first image and every time after
> that, the same large image is shown regardless of the thumbnail. In
> other words, they treat the link "/images/merged.png" as it has the
> same image each time, when it doesn't.
>
> So, I have several options to solve this, but I was wondering if
> there was a way to force a browser not to cache images?
>
> I tried using this:
>
> // expires on any past date
> header ("Expires: Mon, 26 Jul 1997 05:00: GMT");
>
> // last modified at current date and time
> header ("Last-Modified: " . gmdate("D, d M Y H:i:s") . "GMT");
>
> // for HTTP 1.1:
> header ("Cache-Control: no-store, no-cache, must-revalidate");
> header ("Cache-Control: post-check=0, pre-check=0", false);
>
> // for HTTP 1.0
> header ("Pragma: no-cache");
>
> However, it works only IF the user refreshes their browser.
>
> Any ideas before I jump back into this?
>
> Thanks.
>
> tedd
> --
> --------------------------------------------------------------------------------
> http://sperling.com
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


-- 
Like Music?
http://l-i-e.com/artists.htm

-- 
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