Home  >  Article  >  Backend Development  >  Various operating methods of PHP browser cache_PHP tutorial

Various operating methods of PHP browser cache_PHP tutorial

WBOY
WBOYOriginal
2016-07-13 16:59:42942browse

The header() function in PHP sends specific cache-control raw HTTP headers. header() must be called before any actual output, whether from ordinary HTML tags, empty lines or PHP. In the Chinese environment, a full-width space can also cause hard-to-find errors

 代码如下 复制代码

//下面的语句设置此页面的过期时间(用格林威治时间表示),只要是已经过去的日期即可。
header("Expires: Mon, 26 Jul 1970 05:00:00 GMT");

//下面的语句设置此页面的最后更新日期(用格林威治时间表示)为当天,可以强迫浏览器获取最新资料
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");

//告诉客户端浏览器不使用缓存,HTTP 1.1 协议
header("Cache-Control: no-cache, must-revalidate");

//告诉客户端浏览器不使用缓存,兼容HTTP 1.0 协议
header("Pragma: no-cache");

?>

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/631300.htmlTechArticleThe header() function in PHP sends specific cache control original HTTP headers. header() must be in any Called before actual output, whether from regular HTML markup, blank lines or PHP. ...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn