Forum Moderators: coopster

Message Too Old, No Replies

Caching

I don't want the pages to be cached

         

DrDoc

8:58 pm on Feb 24, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



At the very top of my PHP script I have:

header("Cache-Control: no-cache, must-revalidate");
header("Pragma: no-cache");

However, IE doesn't seem to care :(
It still caches the pages... Any idea what might be wrong?

Normally I would put all this in .htaccess, but the @$%# who initially installed Apache compiled PHP/Perl/MySQL etc as dependencies of Apache, instead of loading them as modules. And, neither mod_expires nor mod_headers were compiled with Apache. So, if I wanted to either mod_, I would have to recompile not only Apache but also MySQL/PHP/Perl... (as far as I can tell). Either way, I'm not in the mood to recompile Apache at all :)

So, the reason why the PHP headers are failing -- is that related to the absence of mod_expires or mod_headers? Is there anything I can do to get the browser to not cache the page?

Any help is, as always, greatly appreciated.

:)

coopster

9:57 pm on Feb 24, 2004 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



>>Any idea what might be wrong?

Yes! IE doesn't seem to care.
hehehe, sorry, couldn't help it. stupid IE.

I don't believe the absence of mod_expires or mod_headers has anything to do with your solution not working since the PHP header function sends raw HTTP headers.

Have you tried the example in the PHP header [php.net] manual pages?

DrDoc

9:59 pm on Feb 24, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Have not tried that example yet... But I'll do that.

I don't believe the absence of mod_expires or mod_headers has anything to do with

That's what I was thinking too... Which is why it puzzles me...

coopster

10:04 pm on Feb 24, 2004 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



You can also view the headers with the WebmasterWorld Server Headers [webmasterworld.com] testing tool. This link can be found in your control panel.

DrDoc

10:26 pm on Feb 24, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hmm... I have used the Server Headers tool in the past. But of course it didn't cross my mind to do so now. And, of course it's not sending out the right headers :(

Aha! I found the culprit! The session cache-limiter was set to private, causing the other headers to fail :)

jdMorgan

1:10 am on Feb 25, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



DrDoc,

The cache-control header "no-cache" refers to public caches. You might want to try "no-store".

Jim

DrDoc

1:51 am on Feb 25, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Ya, I'm using the example from the PHP headers manual page:

<?php
// Date in the past
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");

// Always modified
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");

// HTTP/1.1
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);

// HTTP/1.0
header("Pragma: no-cache");
?>