Page 1 of 1

PHP caching problem when host under Linux

Posted: Mon Jun 21, 2004 12:01 am
by seevali
Hi all,
I am doing a shopping cart for music site. My problem is when i add an item to the shopping cart it displays properly. If i add another item to the cart it won't display unless i press Ctrl + Refresh(F5) key combination. Same thing happen if i delete item from the cart. Even though it gets deleted from the database, when i click show cart button it will display the deleted item also. Within the PHP i clear the cache using following code.

header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");

but this works fine on my localhost which on windows. When i run this on Linux it wouldn't work.

I am sure this is a cache problem but not on the browser may be on the server or session cache. Why i am saying so same browse would work fine when the programs host on windows. I use apache 2.0.48 / PHP 4.3.1 and Mysql 3.23.

Any suggestions ???

Posted: Mon Jun 21, 2004 1:03 am
by feyd
have you tried passing the Date header?

there are many examples of getting no-caching to work on the php manual page for [php_man]header[/php_man]();

Posted: Mon Jun 21, 2004 1:40 am
by seevali
I have used Expires header but no use.

I have gone through the PHP Manual thoroughly. But couldn't find a solution.

Posted: Mon Jun 21, 2004 4:30 pm
by pickle
I work solely on Linux systems and these 3 in combination have never failed me:

Code: Select all

header("Cache-control: no-cache");
header("Pragma: no-cache");
header("Expires: 0");
The last one is necessary to stop IE 6 from caching.

Posted: Tue Jun 22, 2004 11:08 pm
by seevali
Thanks.
Itried this also. but didn't work.

header("Expires: 0");

I identified the problem. Problem occurs when the request going through the proxy server. When i bypass the proxy server it works fine.

I used this to clear proxy cache. but still didn't work out for me.
header("Cache-Control: private, no-store, no-cache, must-revalidate");

Documentation says use "private" to clear the proxy cache. Still no luck.
Any idea how to clear the proxy server cache ?