在 PHP7 中,可以通过以下几种方式禁止缓存:
在 PHP 文件的开头使用以下代码:
header("Cache-Control: no-store, no-cache, must-revalidate, max-age=0");
header("Expires: Sat, 26 Jul 1997 05:00:00 GMT");
这将设置响应头,指示浏览器不要缓存页面。
在 PHP 文件的开头使用以下代码:
header("Pragma: no-cache");
header("Cache-Control: no-store, no-cache, must-revalidate, max-age=0");
header("Expires: Sat, 26 Jul 1997 05:00:00 GMT");
这将设置响应头,指示浏览器不要缓存页面。
在 HTML 页面的 <head>
标签中添加以下代码:
<meta http-equiv="Cache-Control" content="no-store, no-cache, must-revalidate, max-age=0">
<meta http-equiv="Pragma" content="no-cache">
<meta http-equiv="Expires" content="Sat, 26 Jul 1997 05:00:00 GMT">
这将设置 HTML 页面的元标记,指示浏览器不要缓存页面。
请注意,这些方法仅仅是向浏览器发出指示,告诉它不要缓存页面。浏览器可能会选择忽略这些指示。
Laravel PHP 深圳智简公司。版权所有©2023-2043 LaravelPHP 粤ICP备2021048745号-3
Laravel 中文站