Page 1 of 1

defining NO-CAHCE in php

Posted: Mon Dec 27, 2004 8:49 am
by pelegk2
how do i define no cache in php pages'like in asp
where it tells the browser not to use the cache?
thnaks in advance
peleg

Posted: Mon Dec 27, 2004 9:26 am
by feyd
[php_man]header[/php_man]

Posted: Mon Dec 27, 2004 11:28 am
by Joe
Straight from the manual:

Code: Select all

<?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");
?>
Remember to put this at the very top of the page before any output.