It's caching an image based on it's URL, so clearly, the browser is not
looking for another pic if the URL is the same, based on the settings you
have for caching in your browser.  Other people's results will vary.

The no cache headers on the images SHOULD help, as would no cache headers on
the calling HTML file, but the easiest way is to get a random number, and
tap it onto the query string:

Put this code in your shared library of functions (adapted from manual,
untested):
<?
function randNumber($min=1000,$max=99999)
    {
    // build a seed
    list($usec, $sec) = explode(' ', microtime());
    $seed = (float) $sec + ((float) $usec * 100000);

    // seed random generator
    srand($seed);

    // return random number
    return rand($min,$max);
    }
?>

Then when calling your images, call them with a random number attached:

<IMG SRC="makepic.php?opt1=abc&opt2=def&r=<?php echo randNumber(); ?>">


The browser will (mostly) see a "new" image URL and look at the server for
it, rather than looking in cache.


Justin



on 13/03/03 3:49 AM, Mark Wilson ([EMAIL PROTECTED]) wrote:

> I have a PHP page which in turn calls an image-creating PHP program,
> like so:
> ...(calling page: mypage.php)..
> <body>
> <IMG SRC="makepic.php?opt1=abc&opt2=def">
> ....
> </body>
> </html>
> 
> 
> makepic.php does database lookups using the values of opt1 and opt2,
> then creates a graphic (PNG) using that data and returns the graphic.
> So far, so good... but the graphic is being cached, so the data is not
> always up-to-date, unless I do a shift-reload of the calling page.
> I tried adding a "pragma nocache" line to the HEAD of mypage.php,
> but that had no effect. I don't want to tell my users to always do a
> shift-reload - how can I force either mypage.php to not cache
> the graphic, or get makepic.php's output to not be cached????
> Thanks... replies to [EMAIL PROTECTED]
> 
> 


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

Reply via email to