The code that disables page caching in PHP is fairly straightforward, as long as you use the PHP header () browser to send a cache-control:no-cache or set the page cache expiration time for you before today.
Some friends say the simplest way to disable page caching
The code is as follows |
Copy Code |
Header ("Cache-control:no-cache, must-revalidate"); |
Here I'll give you some PHP code to use:
The code is as follows |
Copy Code |
Header ("Expires:mon, Jul 1997 05:00:00 GMT"); Header ("Cache-control:no-cache, must-revalidate"); Header ("Pragma:no-cache"); |
Let's take a look at the HTTP response message, in fact we can use the Telnet command to view, below I give the point HTTP response content: http/1.1 OK
server:microsoft-iis/6.0
Date:thu, Oct 11:20:53 GMT
Content-type:text/html
Set-cookie:name=value; path=/
Cache-control:private
Let's take a look at the details below.
The code is as follows |
Copy Code |
Set the expiration time for this page (in GMT), as long as the date has passed. Header ("Expires:mon, Jul 1970 05:00:00 GMT");
Set the last update date for this page (expressed in GMT) to force the browser to get the latest information for the current day Header ("last-modified:".) Gmdate ("D, D M Y h:i:s"). "GMT");
Tells the client browser not to use the cache, HTTP 1.1 protocol Header ("Cache-control:no-cache, must-revalidate");
Tells the client browser not to use the cache, compatible with the HTTP 1.0 protocol Header ("Pragma:no-cache");
|
?>
Just put the above code at the very beginning of your PHP page, or the header function might go wrong. So you have to put it at the beginning of the document.
http://www.bkjia.com/PHPjc/631282.html www.bkjia.com true http://www.bkjia.com/PHPjc/631282.html techarticle The code that prohibits page caching in PHP is fairly straightforward, as long as you use the PHP header () browser to send a cache-control:no-cache or set the page cache expiration time for you before today ...