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 ???
PHP caching problem when host under Linux
Moderator: General Moderators
I work solely on Linux systems and these 3 in combination have never failed me:
The last one is necessary to stop IE 6 from caching.
Code: Select all
header("Cache-control: no-cache");
header("Pragma: no-cache");
header("Expires: 0");Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
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 ?
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 ?