Re: [PHP] Force refresh of graphic - how?

2003-03-17 Thread Steve Magruder
<[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> Thanks for your suggestions. I had been thinking that it
> must be the URL that was causing the caching (same URL,
> same thing, right? Sounds good...), so I was planning
> on trying something along the lines of what you suggest.
> But I was thinking, why a random number? Why not just
> append the current time value? (time()) ... it won't be
> the same for any single user more than once, so that
> should force the re-fetch of the graphic, just like the
> random would. Shouldn't this work too? (Said he without
> having time to test either approach!)

Yes, that should work.

Steve



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



Re: [PHP] Force refresh of graphic - how?

2003-03-16 Thread Justin French
Ok, thanks for the tip :)

Justin


on 13/03/03 7:53 PM, Ernest E Vogelsinger ([EMAIL PROTECTED]) wrote:

> At 23:33 12.03.2003, Justin French said:
> [snip]
>> Put this code in your shared library of functions (adapted from manual,
>> untested):
>> > function randNumber($min=1000,$max=9)
>> {
>> // build a seed
>> list($usec, $sec) = explode(' ', microtime());
>> $seed = (float) $sec + ((float) $usec * 10);
>> 
>> // seed random generator
>> srand($seed);
>> 
>> // return random number
>> return rand($min,$max);
>> }
>> ?>
> [snip]
> 
> May I?
> 
> It's usually not a good idea to re-seed the randum number generator during
> a single script instance, as this might use the same seed more than once,
> resulting in the identical random sequence...
> 
> To avoid reseeding, you could e.g. use a static variable in your
> randNumber() function:
> 
> function randNumber($min=1000,$max=9)
> {
> static $is_seeded = false;
> if (!$is_seeded) {
> $is_seeded = true;
> // build a seed
> list($usec, $sec) = explode(' ', microtime());
> $seed = (float) $sec + ((float) $usec * 10);
> // seed random generator
> srand($seed);
> }
> ...
> 
> I prefer to add a string generated by uniqid(), such as
> 
> 
> uniqid() uses the entropy generated by the opsys random device (if
> available) in an attempt to make this truly random.
> 
> 
> 


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



Re: [PHP] Force refresh of graphic - how?

2003-03-13 Thread WilsonCPU
Thanks for your suggestions. I had been thinking that it
must be the URL that was causing the caching (same URL,
same thing, right? Sounds good...), so I was planning
on trying something along the lines of what you suggest.
But I was thinking, why a random number? Why not just 
append the current time value? (time()) ... it won't be
the same for any single user more than once, so that
should force the re-fetch of the graphic, just like the
random would. Shouldn't this work too? (Said he without
having time to test either approach!)

- Mark


---
Mark Wilson, Computer Programming Unlimited
Web:   http://www.cpuworks.com/
Email: [EMAIL PROTECTED]
Our motto: "Getting the Job Done"

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



Re: [PHP] Force refresh of graphic - how?

2003-03-13 Thread Ernest E Vogelsinger
At 23:33 12.03.2003, Justin French said:
[snip]
>Put this code in your shared library of functions (adapted from manual,
>untested):
>function randNumber($min=1000,$max=9)
>{
>// build a seed
>list($usec, $sec) = explode(' ', microtime());
>$seed = (float) $sec + ((float) $usec * 10);
>
>// seed random generator
>srand($seed);
>
>// return random number
>return rand($min,$max);
>}
>?>
[snip] 

May I?

It's usually not a good idea to re-seed the randum number generator during
a single script instance, as this might use the same seed more than once,
resulting in the identical random sequence...

To avoid reseeding, you could e.g. use a static variable in your
randNumber() function:

function randNumber($min=1000,$max=9)
   {
static $is_seeded = false;
if (!$is_seeded) {
$is_seeded = true;
   // build a seed
   list($usec, $sec) = explode(' ', microtime());
   $seed = (float) $sec + ((float) $usec * 10);
   // seed random generator
   srand($seed);
}
...

I prefer to add a string generated by uniqid(), such as


uniqid() uses the entropy generated by the opsys random device (if
available) in an attempt to make this truly random.




-- 
   >O Ernest E. Vogelsinger
   (\)ICQ #13394035
^ http://www.vogelsinger.at/



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



Re: [PHP] Force refresh of graphic - how?

2003-03-12 Thread Justin French
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):


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




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



Re: [PHP] Force refresh of graphic - how?

2003-03-12 Thread Ray Hunter
You can use the meta tags to do a refresh of the browser page...

example:
 

after content you add the seconds of delay before refresh...

More info on the meta tag:
http://www.xs4all.nl/~dimaroan/htl/index.html

--
Ray

On Wed, 2003-03-12 at 09:49, Mark Wilson wrote:
> I have a PHP page which in turn calls an image-creating PHP program,
> like so:
> ...(calling page: mypage.php)..
> 
> 
> 
> 
> 
> 
> 
> 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



[PHP] Force refresh of graphic - how?

2003-03-12 Thread Mark Wilson
I have a PHP page which in turn calls an image-creating PHP program,
like so:
...(calling page: mypage.php)..







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