PHP caching problem when host under Linux

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
seevali
Forum Newbie
Posts: 10
Joined: Wed May 12, 2004 3:27 am

PHP caching problem when host under Linux

Post 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 ???
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post 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]();
seevali
Forum Newbie
Posts: 10
Joined: Wed May 12, 2004 3:27 am

Post by seevali »

I have used Expires header but no use.

I have gone through the PHP Manual thoroughly. But couldn't find a solution.
User avatar
pickle
Briney Mod
Posts: 6445
Joined: Mon Jan 19, 2004 6:11 pm
Location: 53.01N x 112.48W
Contact:

Post 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.
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
seevali
Forum Newbie
Posts: 10
Joined: Wed May 12, 2004 3:27 am

Post 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 ?
Post Reply