Re: [PHP] Re: Weird caching problem with PHP4/Apache
On Wednesday 31 October 2001 14:48, René Fournier wrote: Nope, unfortunately, nothing. It's a really weird problem. It's like the PHP function I wrote for generating the random image will only work the first time. I think it is not php that caches it. As I undertsand you wrote a script that generates an image, and give it back to the browser in an img src=... html tag. Am I right? I hope I am, so I continue :)) Images can be cached in many places (proxies, browser), but definietly not in php. Your script that generates in the image and should be called every time by the img html tag, won't ever called again if the previous image were stored somewhere. You should send pragma no-cache and other http headers (many posts were on this cache headers topic) from the script that generates and gives back the image. Or another sollution is that you can call your script with a random number or better with the current date and time, so you images's name won't be the same, and caches can't give back the old image. for example: ?php echoimg src=\generatebackground.php?x=.date(YmdHis). \;? Arpi -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
RE: [PHP] Re: Weird caching problem with PHP4/Apache -- THE SAGA CONTINUES
Here's what I've got, starting at the top... == ?php header ('Expires: Mon, 26 Jul 1997 05:00:00 GMT');// Date in the past header ('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT'); // always modified header ('Cache-Control: no-cache, must-revalidate'); // HTTP/1.1 header ('Pragma: no-cache'); // HTTP/1.0 ?html head titleTitle/title META HTTP-EQUIV=Expires CONTENT=0 meta http-equiv=Content-Type content=text/html; charset=iso-8859-1 [SNIP] ?php function randbg() { $num_of_bgs = 5; $the_one = rand(1,$num_of_bgs); echo bg.$the_one..jpg; } ? [SNIP] td valign=top align=left background=../common/images/bg/?php randbg(); ? == Here's why I think it's PHP4: If I look at these pages on my local machine (WinME, Apache 1.3.20, PHP4.06 module, MySQL 3.23.14 (not that it matters, right?)), the randbg() function works as it should--I get a random background image everytime. But if I look at these EXACT SAME pages on Fatcow (Linux/Apache, I believe, PHP4...), the randbg() function executes the first time, then [seemingly] fails to execute again--it never generates a different, random bakground. (Or maybe I'm looking at one hell of a coincidence :-) So my question is, who is caching what, where? ...Rene -Original Message- From: Tamas Arpad [mailto:[EMAIL PROTECTED]] Sent: Wednesday, October 31, 2001 7:24 AM To: René Fournier; Hugh Danaher Cc: Php-General Subject: Re: [PHP] Re: Weird caching problem with PHP4/Apache On Wednesday 31 October 2001 14:48, René Fournier wrote: Nope, unfortunately, nothing. It's a really weird problem. It's like the PHP function I wrote for generating the random image will only work the first time. I think it is not php that caches it. As I undertsand you wrote a script that generates an image, and give it back to the browser in an img src=... html tag. Am I right? I hope I am, so I continue :)) Images can be cached in many places (proxies, browser), but definietly not in php. Your script that generates in the image and should be called every time by the img html tag, won't ever called again if the previous image were stored somewhere. You should send pragma no-cache and other http headers (many posts were on this cache headers topic) from the script that generates and gives back the image. Or another sollution is that you can call your script with a random number or better with the current date and time, so you images's name won't be the same, and caches can't give back the old image. for example: ?php echoimg src=\generatebackground.php?x=.date(YmdHis). \;? Arpi -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] Re: Weird caching problem with PHP4/Apache -- THE SAGA CONTINUES
On Wednesday 31 October 2001 18:18, René Fournier wrote: Here's what I've got, starting at the top... == ?php header ('Expires: Mon, 26 Jul 1997 05:00:00 GMT');// Date in the past header ('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT'); // always modified header ('Cache-Control: no-cache, must-revalidate'); // HTTP/1.1 header ('Pragma: no-cache'); // HTTP/1.0 ?html head titleTitle/title META HTTP-EQUIV=Expires CONTENT=0 meta http-equiv=Content-Type content=text/html; charset=iso-8859-1 [SNIP] ?php function randbg() { $num_of_bgs = 5; $the_one = rand(1,$num_of_bgs); echo bg.$the_one..jpg; } ? [SNIP] td valign=top align=left background=../common/images/bg/?php randbg(); ? == Ah, so you have bg1.jpg, bg2.jpg and so on till 5. And want to show one of them selected by a random value? So when you click on browser's refresh button, what happens? You always get the same page as before with for example bg1.jpg? Do you seed the random number generator (srand()) before you use rand() function? Arpi Here's why I think it's PHP4: If I look at these pages on my local machine (WinME, Apache 1.3.20, PHP4.06 module, MySQL 3.23.14 (not that it matters, right?)), the randbg() function works as it should--I get a random background image everytime. But if I look at these EXACT SAME pages on Fatcow (Linux/Apache, I believe, PHP4...), the randbg() function executes the first time, then [seemingly] fails to execute again--it never generates a different, random bakground. (Or maybe I'm looking at one hell of a coincidence :-) So my question is, who is caching what, where? ...Rene -Original Message- From: Tamas Arpad [mailto:[EMAIL PROTECTED]] Sent: Wednesday, October 31, 2001 7:24 AM To: René Fournier; Hugh Danaher Cc: Php-General Subject: Re: [PHP] Re: Weird caching problem with PHP4/Apache On Wednesday 31 October 2001 14:48, René Fournier wrote: Nope, unfortunately, nothing. It's a really weird problem. It's like the PHP function I wrote for generating the random image will only work the first time. I think it is not php that caches it. As I undertsand you wrote a script that generates an image, and give it back to the browser in an img src=... html tag. Am I right? I hope I am, so I continue :)) Images can be cached in many places (proxies, browser), but definietly not in php. Your script that generates in the image and should be called every time by the img html tag, won't ever called again if the previous image were stored somewhere. You should send pragma no-cache and other http headers (many posts were on this cache headers topic) from the script that generates and gives back the image. Or another sollution is that you can call your script with a random number or better with the current date and time, so you images's name won't be the same, and caches can't give back the old image. for example: ?php echoimg src=\generatebackground.php?x=.date(YmdHis). \;? Arpi -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
RE: [PHP] Re: Weird caching problem with PHP4/Apache -- THE SAGA CONTINUES
Yes! That's it! I added that srand function, and it works great. Thanks! ..Rene -Original Message- From: Tamas Arpad [mailto:[EMAIL PROTECTED]] Sent: Wednesday, October 31, 2001 10:58 AM To: René Fournier Cc: Php-General Subject: Re: [PHP] Re: Weird caching problem with PHP4/Apache -- THE SAGA CONTINUES On Wednesday 31 October 2001 18:18, René Fournier wrote: Here's what I've got, starting at the top... == ?php header ('Expires: Mon, 26 Jul 1997 05:00:00 GMT');// Date in the past header ('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT'); // always modified header ('Cache-Control: no-cache, must-revalidate'); // HTTP/1.1 header ('Pragma: no-cache'); // HTTP/1.0 ?html head titleTitle/title META HTTP-EQUIV=Expires CONTENT=0 meta http-equiv=Content-Type content=text/html; charset=iso-8859-1 [SNIP] ?php function randbg() { $num_of_bgs = 5; $the_one = rand(1,$num_of_bgs); echo bg.$the_one..jpg; } ? [SNIP] td valign=top align=left background=../common/images/bg/?php randbg(); ? == Ah, so you have bg1.jpg, bg2.jpg and so on till 5. And want to show one of them selected by a random value? So when you click on browser's refresh button, what happens? You always get the same page as before with for example bg1.jpg? Do you seed the random number generator (srand()) before you use rand() function? Arpi Here's why I think it's PHP4: If I look at these pages on my local machine (WinME, Apache 1.3.20, PHP4.06 module, MySQL 3.23.14 (not that it matters, right?)), the randbg() function works as it should--I get a random background image everytime. But if I look at these EXACT SAME pages on Fatcow (Linux/Apache, I believe, PHP4...), the randbg() function executes the first time, then [seemingly] fails to execute again--it never generates a different, random bakground. (Or maybe I'm looking at one hell of a coincidence :-) So my question is, who is caching what, where? ...Rene -Original Message- From: Tamas Arpad [mailto:[EMAIL PROTECTED]] Sent: Wednesday, October 31, 2001 7:24 AM To: René Fournier; Hugh Danaher Cc: Php-General Subject: Re: [PHP] Re: Weird caching problem with PHP4/Apache On Wednesday 31 October 2001 14:48, René Fournier wrote: Nope, unfortunately, nothing. It's a really weird problem. It's like the PHP function I wrote for generating the random image will only work the first time. I think it is not php that caches it. As I undertsand you wrote a script that generates an image, and give it back to the browser in an img src=... html tag. Am I right? I hope I am, so I continue :)) Images can be cached in many places (proxies, browser), but definietly not in php. Your script that generates in the image and should be called every time by the img html tag, won't ever called again if the previous image were stored somewhere. You should send pragma no-cache and other http headers (many posts were on this cache headers topic) from the script that generates and gives back the image. Or another sollution is that you can call your script with a random number or better with the current date and time, so you images's name won't be the same, and caches can't give back the old image. for example: ?php echoimg src=\generatebackground.php?x=.date(YmdHis). \;? Arpi -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP] Re: Weird caching problem with PHP4/Apache
These lines will do what you asked, but I am unsure if they will resolve your problem (since I don't know Fatcow and how they configured the server). Anyway, here it is: header ('Expires: Mon, 26 Jul 1997 05:00:00 GMT');// Date in the past header ('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT'); // always modified header ('Cache-Control: no-cache, must-revalidate'); // HTTP/1.1 header ('Pragma: no-cache'); // HTTP/1.0 PS: Got it from the manual, header(); function :-) Check the online comments if any problems happen, since there are many various flavors of servers and clients... -- Julio Nobrega A hora está chegando: http://toca.sourceforge.net René fournier [EMAIL PROTECTED] wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... Having successfully uploaded my PHP4+MySQL site finally to Fatcow (and the MySQL stuff IS there--thanks for the help), I'm now left with making it actually work online. One curious problem: For every page in the site (*.php4), I include three parts, a header.inc (common to all), a body.inc (unique to each .php4 file), and a footer.inc (common to all). One of the things the header.inc file does is generate select a background image randomly. Very simple, and it works on my local machine. But as soon as I look at the page online, it seems Fatcow (Apache/Zend?)caches the header.inc file--that is, the results of the php script inside it, which generates the random background. I say this because no matter how many pages I look at, refreshing them, etc., I always get sent the same original background image. Even if I replace now the random background image function in header.inc with the explicit name of a different file, it STILL displays the same one. Weird? Is there some way to ensure that each PHP4 file/script is interpreted every single time, and not cached (as it seems)?? ...Rene -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
RE: [PHP] Re: Weird caching problem with PHP4/Apache
Thanks for the help, but I'm afraid it hasn't solved the caching problem, at least not with respect to the PHP random function... It's not as if the entire page get's cached, since there is an SQL query that selects a random row from a table--and that is random. But the PHP part of it--that is, where the background image of a table row is randomly selected--is static. Refreshing doesn't help, nor does this code, which I put in my header.inc file: ?php header ('Expires: Mon, 26 Jul 1997 05:00:00 GMT');// Date in the past header ('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT'); // always modified header ('Cache-Control: no-cache, must-revalidate'); // HTTP/1.1 header ('Pragma: no-cache'); // HTTP/1.0 ?html head titleMy Site/title META HTTP-EQUIV=Expires CONTENT=0 meta http-equiv=Content-Type content=text/html; charset=iso-8859-1 link rel=stylesheet href=../common/styles.css type=text/css script language=JavaScript !-- You'll notice that I've got both that header function AND a meta tag, each of which should tell Apache not to cache, but here's what I think is happening: Apache is NOT caching, since the SQL select statements are running randomly. I think the cache problem is with PHP/Zend, since I'm using PHP4. So... Is there a way to force PHP to reexecute every time without configuring the server differently (since I can't)?? -Original Message- From: Julio Nobrega Trabalhando [mailto:[EMAIL PROTECTED]] Sent: Tuesday, October 30, 2001 9:31 AM To: [EMAIL PROTECTED] Subject: [PHP] Re: Weird caching problem with PHP4/Apache These lines will do what you asked, but I am unsure if they will resolve your problem (since I don't know Fatcow and how they configured the server). Anyway, here it is: header ('Expires: Mon, 26 Jul 1997 05:00:00 GMT');// Date in the past header ('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT'); // always modified header ('Cache-Control: no-cache, must-revalidate'); // HTTP/1.1 header ('Pragma: no-cache'); // HTTP/1.0 PS: Got it from the manual, header(); function :-) Check the online comments if any problems happen, since there are many various flavors of servers and clients... -- Julio Nobrega A hora está chegando: http://toca.sourceforge.net René fournier [EMAIL PROTECTED] wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... Having successfully uploaded my PHP4+MySQL site finally to Fatcow (and the MySQL stuff IS there--thanks for the help), I'm now left with making it actually work online. One curious problem: For every page in the site (*.php4), I include three parts, a header.inc (common to all), a body.inc (unique to each .php4 file), and a footer.inc (common to all). One of the things the header.inc file does is generate select a background image randomly. Very simple, and it works on my local machine. But as soon as I look at the page online, it seems Fatcow (Apache/Zend?)caches the header.inc file--that is, the results of the php script inside it, which generates the random background. I say this because no matter how many pages I look at, refreshing them, etc., I always get sent the same original background image. Even if I replace now the random background image function in header.inc with the explicit name of a different file, it STILL displays the same one. Weird? Is there some way to ensure that each PHP4 file/script is interpreted every single time, and not cached (as it seems)?? ...Rene -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]