Many people may not know that dynamic Web pages can also be cached in the browser. The following is a PHP script as an example of how to set up a dynamic Web page in the browser cache
Set page expiration time to 1 hours
$duetime = 3600*24*30;
//Get browser will transfer to server last-modified Header
$modify _time = $_server[' http_if_modified_since ');
//When the browser accesses the webpage again within the set time, send the HTTP 304 status code, which saves the amount of data transferred.
if (Strtotime ($modify _time) + $duetime > Time ())
{
Header (' http/1.1 304 ');
Exit (1);
}
Header (' connection:keep-alive ');
//Set up Web pages last-modified Header
Header (' last-modified: '. Gmdate (' d, D M Y h:i:s '). ' GMT ');
Set Page Expiration time
Header (' Expires: '. Gmdate (' d, D M Y h:i:s ', time () + $duetime). ' GMT ');
//execute cache for a long time, with Expires a bit similar, allows us to more fully control the page expiration time, because the browser time may not be coordinated with the server time, with Cache-control header can be limited
Header (' cache-control:max-age= '. $duetime);
Output content
......
?>
Original: http://woqilin.blogspot.com/2014/05/php.html
The above describes the PHP settings Dynamic Web page in the browser cache, including dynamic Web pages, browser content, I hope to be interested in PHP tutorial friends helpful.