我一直在使用 Visual Studio 进行编程,但是当我对 CSS 或其他文件进行更改时,浏览器会加载最后一个缓存页面,并且我必须在每次测试时手动清理缓存。所以我一直在尝试先清理缓存,但 PHP 标头不起作用。
<?php
header("Cache-Control: no-cache, must-revalidate");
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Content-Type: application/xml; charset=utf-8");
exit;
?>
我已经放置了 php 代码 之前和之后
<!DOCTYPE html>
<html>
标签之前和之后
<header>
标签之前和之后
<body>
标签之前和之后
根据php手册站点
请记住,必须在发送任何实际输出之前调用
,无论是通过普通 HTML 标签、文件中的空行还是从 PHP。header()
这意味着它必须放在html标签之前。但这给了我错误:
显示此错误:
This page contains the following errors:
error on line 4 at column 1: Start tag expected, '<' not found
Below is a rendering of the page up to the first error.
如果我删除标题,代码就可以正常工作
在 Chrome 浏览器中。
还尝试了该功能:
clearstatcache(bool $clear_realpath_cache = false, string $filename = ""): void
但它不起作用,或者我不知道如何或在哪里实施。