Forum Moderators: phranque

Message Too Old, No Replies

http header for "dont cache"?

help with http headers

         

Nick_W

10:38 am on Nov 8, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hi all, I have a site I nead to make certain that each and every time a user comes to the page they have to request the page rather than have their browser show the cached version....

Can someone please tell me how to do this?

Thanks....

Nick

andreasfriedrich

10:53 am on Nov 8, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



<?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");
?>

[php.net...]

Syren_Song

1:40 pm on Nov 8, 2002 (gmt 0)

10+ Year Member



In straight html, you can put these in your header:

* <META HTTP-EQUIV="Pragma" CONTENT="no-cache">
* <META HTTP-EQUIV="Expires" CONTENT="0">

The first works for NN, the second for IE.

Nick_W

1:41 pm on Nov 8, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Great, thanks guys!

Nick

brotherhood of LAN

2:32 pm on Nov 8, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Nick, check out W3C [w3.org] for side info.

Now I see why the "There's more than one way to do it" comes about now.......they should have only one way in which to keep a page non-cached IMO :)

dhdweb

2:25 pm on Nov 9, 2002 (gmt 0)

10+ Year Member



andreas,

Does your solution work with the AOL cache problem aswell?

andreasfriedrich

10:03 pm on Nov 9, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I believe it does. Have a look at [webmaster.info.aol.com...] for more infos.

Andreas

jdMorgan

12:32 am on Nov 10, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Brotherhood of LAN,

And just to confuse the "more than one way to do it" issue even more... :)

Set expiry date and cache control in Apache using mod_headers in .htaccess :

# Set http header cache expiry dates
ExpiresActive On
# Default - Expire everything 1 week from last access, declare must-revalidate
ExpiresDefault A604800
Header append Cache-Control: "must-revalidate"
# Apply a customized Cache-Control header to frequently-updated files
<Files test.html>
Header unset Cache-Control:
ExpiresDefault A0
Header append Cache-Control: "no-cache, must-revalidate"
</Files>

Jim