Re: [PHP] Force refresh of graphic - how?
<[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?
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?
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?
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?
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?
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
Re: [PHP] force refresh?
i'll give it a try... jeff. "Sam Masiello" <[EMAIL PROTECTED]> wrote in message 002001c1affa$9aa56560$6300fa0a@dev">news:002001c1affa$9aa56560$6300fa0a@dev... > > You can force the browser to refresh using a meta tag: > > > > This will cause the page to refresh every 180 seconds. > > HTH > > Sam Masiello > Software Quality Assurance Engineer > Synacor > (716) 853-1362 X289 > [EMAIL PROTECTED] > > - Original Message - > From: "Chris Wright" <[EMAIL PROTECTED]> > To: <[EMAIL PROTECTED]> > Sent: Thursday, February 07, 2002 11:34 AM > Subject: RE: [PHP] force refresh? > > > Probably only by writing javascript to the window using php. > > --- > Christopher Wright > 303 447 2496 x 107 > www.netinfra.com > > "We'll take care of it." > > "Net Infrastructure has definitely helped our company, even though we're > not in the US, Net Infrastructure has been a key part in the success of > our business." Juan Carlos Saravia > > > -Original Message- > From: Jeff D. Hamann [mailto:[EMAIL PROTECTED]] > Sent: Thursday, February 07, 2002 9:02 AM > To: [EMAIL PROTECTED] > Subject: [PHP] force refresh? > > > can i force a browser to refresh using php. > > jeff. > > -- > Jeff D. Hamann > Hamann, Donald & Associates, Inc. > PO Box 1421 > Corvallis, Oregon USA 97339-1421 > Bus. 541-753-7333 > Cell. 541-740-5988 > [EMAIL PROTECTED] > www.hamanndonald.com > > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] force refresh?
Jeff, > can i force a browser to refresh using php. =the issue is PHP's server-side-edness. Consider adding an HTML META tag to the page, to call/renew itself every n-seconds. =dn -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] force refresh?
You can force the browser to refresh using a meta tag: This will cause the page to refresh every 180 seconds. HTH Sam Masiello Software Quality Assurance Engineer Synacor (716) 853-1362 X289 [EMAIL PROTECTED] - Original Message - From: "Chris Wright" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Thursday, February 07, 2002 11:34 AM Subject: RE: [PHP] force refresh? Probably only by writing javascript to the window using php. --- Christopher Wright 303 447 2496 x 107 www.netinfra.com "We'll take care of it." "Net Infrastructure has definitely helped our company, even though we're not in the US, Net Infrastructure has been a key part in the success of our business." Juan Carlos Saravia -Original Message- From: Jeff D. Hamann [mailto:[EMAIL PROTECTED]] Sent: Thursday, February 07, 2002 9:02 AM To: [EMAIL PROTECTED] Subject: [PHP] force refresh? can i force a browser to refresh using php. jeff. -- Jeff D. Hamann Hamann, Donald & Associates, Inc. PO Box 1421 Corvallis, Oregon USA 97339-1421 Bus. 541-753-7333 Cell. 541-740-5988 [EMAIL PROTECTED] www.hamanndonald.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] force refresh?
Probably only by writing javascript to the window using php. --- Christopher Wright 303 447 2496 x 107 www.netinfra.com "We'll take care of it." "Net Infrastructure has definitely helped our company, even though we're not in the US, Net Infrastructure has been a key part in the success of our business." Juan Carlos Saravia -Original Message- From: Jeff D. Hamann [mailto:[EMAIL PROTECTED]] Sent: Thursday, February 07, 2002 9:02 AM To: [EMAIL PROTECTED] Subject: [PHP] force refresh? can i force a browser to refresh using php. jeff. -- Jeff D. Hamann Hamann, Donald & Associates, Inc. PO Box 1421 Corvallis, Oregon USA 97339-1421 Bus. 541-753-7333 Cell. 541-740-5988 [EMAIL PROTECTED] www.hamanndonald.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php