Many people may not know that dynamic web pages can also be cached in browsers. The following uses a PHP script as an example to explain how to set up dynamic web pages to be cached in the browser
//Set the web page expiration time to 1 hour
$duetime = 3600*24*30取 // Get the browser to transmit to the server
Last-ModifyHead $ Modify_time = $ _Server ['http_if_modify_since'];
// When the browser sets time to set time When accessing the web page again within a certain period of time, the status code of HTTP
304will be sent, thus saving the amount of data to be transmitted. if(strtotime($modify_time) + $duetime > time())
{
header('HTTP/1.1 304');
exit(1);
}
header('Connection: keep-alive');
//Set up web page
Last-Modifiedheaderheader('Last-Modified: '.gmdate(' D, d M Y H:i:s').' GMT');
//Set the webpage expiration time
header('Expires: '.gmdate('D, d M Y H:i:s', time()+$duetime).' GMT');
//The execution cache time is long, somewhat similar to
Expires,allows us to more comprehensively control the web page expiration time, because the browser time may be different from The server time is not coordinated, and the Cache-Control header can be limited. header('Cache-Control: max-age='.$duetime);
//Output content
...
?>
Original text: http://woqilin.blogspot.com/2014/05/php.html
The above introduces how to set up the browser cache of dynamic web pages in PHP, including dynamic web pages and browser content. I hope it will be helpful to friends who are interested in PHP tutorials.