Forum Moderators: coopster

Message Too Old, No Replies

PHP Header() Problem - Cache Control

Can someone please take a look?

         

Nick_W

8:31 pm on Jul 30, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hi all,

I don't seem to ever manage to get this right. Would someone please have a look at these headers and tell me why my dynamic pages appear to be being cached?


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-store, no-cache, must-revalidate"); // HTTP/1.1
header("Cache-Control: post-check=0, pre-check=0", false);
header("Cache-Control: max-age=0");
header("Pragma: no-cache");

I am of course sending them before anything else. They just don't appear to be doing the job.

Many thanks for help/advice...

Nick

jatar_k

8:35 pm on Jul 30, 2003 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Is it happening all the time or is it in a specific situation? Can you identify any other factors that might be involved?

and would you not post these in perl, hehe ;)

ikbenhet1

8:35 pm on Jul 30, 2003 (gmt 0)

10+ Year Member



header("Cache-Control: post-check=0, pre-check=0", false);
I've not much understanding of this but should that not be:
header("Cache-Control: post-check=0, pre-check=0, false");

sorry if it's a stupid answer.

Nick_W

8:41 pm on Jul 30, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



>>and would you not post these in perl, hehe

Ooops! - Time to update my little Opera Gizmo ;) - Sorry!

>stupid

At this point, NOTHING is stupid hehe! - I'll give it ago.

Here's the scenario. There is a page called view.php which shows a user which products they have bookmarked based on cookies.

When you go to view and you have bookmarks (cookies) it will display the products just fine (retrieving from the db..). When you 'delete all bookmarks', it will give you the 'no more bookmarks' msg just fine.

However, if you surf off round the site again, then get a cookie set by bookmarking another product and then want to go to view.php to see it, guess what? - Yep, you get the 'no more bookmarks' msg again. Refreshing the page gives the correct view...

I've thought about it being a cookie issue but that really doesn't seem it as you are viewing the page after the cookie has been set...

With me?

Nick

jatar_k

8:46 pm on Jul 30, 2003 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



I get it.

though I am not sure why it doesn't show results. Is the cookie being destroyed (expired) when they are done with the bookmarks? or are you just setting it to be empty?

Have you tested to make sure that it is only setting one cookie and that the values are being updated properly when they select a new bookmark once they have deleted them all. It seems like it could be the way you are unsetting it.

I am grasping but it sounds more like a cookie problem than a caching one.

Nick_W

9:09 pm on Jul 30, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Oh, woe is me. I am a fool and a sinner....

It is not a header problem.
It is not a cookie problem.

Is IS a Nick_W problem :(

Because the 'no more bookmarks msg' is just paragraph going through a blank template. There are no nav links, so, When I get to that point, I am using the back button to retrace my steps.

Somewhere along the line that's fouling things up (my brain hurts but I'm sure I can fathom the logic if I try tomorrow...). BUT, if I key in the urls, I have no problems at all ;)

What a pillock.

Many thanks guys, I'm very much obliged for your help....

Nick

jatar_k

9:17 pm on Jul 30, 2003 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



always a pleasure to talk nuts with you.

I can't even count the times I have been messed on back and forward buttons. :)

Nazgulkin

11:44 am on Sep 3, 2003 (gmt 0)



Hi there!
I have similar problem.
My headers are:
header("Expires: " . gmdate("D, d M Y H:i:s") . " GMT");
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Cache-Control: no-cache");
header("Pragma: no-cache");
header("Content-Type: application/octet-stream");
header("Content-Length: $size");
header("Content-Disposition: attachment; filename=\"$name\"");
header("Content-Transfer-Encoding: binary");
header("Content-Description: $name" );

And this does not allow to download the sent file.
BUT!
When i changed headers:
header('Cache-Control: private');
header ("Pragma: private");
everything worked!
But it seemed as it had caching.

If such problem had been solved already by someone please notify me by email or answer my post.