我一直在使用Visual Studio编程,但当我在CSS或其他文件中进行更改时,浏览器会加载最后一个缓存页,我必须在每次测试中手动清除缓存.所以我一直在try 先清理缓存,但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手册站点
请记住,必须在发送任何实际输出之前调用
header()
,无论是通过普通的HTML标记、文件中的空行还是从PHP发送.
这意味着它必须放在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浏览器中.
还try 了该功能:
clearstatcache(bool $clear_realpath_cache = false, string $filename = ""): void
但它不起作用,或者我不知道如何或在哪里实现.