header('Expires: ' . gmdate('D, d M Y H:i:s', time()-1) . ' GMT');
header('Cache-Control: no-store no-cache must-revalidate');
header("Cache-Control:no-cache");
header("Pragma:no-cache");
header("Expires:-1");
echo gmdate('Y-m-d H:i:s');echo '<br>';
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<title>新建网页</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="description" content="" />
<meta name="keywords" content="" />
<script type="text/javascript">
function f1(){
var xhr = new XMLHttpRequest();
xhr.open("get",'./07.php'+Math.random());//1.随机数解决缓存信息
xhr.send(null);
}
</script>
<style type="text/css">
</style>
</head>
<body>
<input type="button" value="触发" onclick="f1()" />
</body>
</html>
<?php
//ajax缓存问题
//2.设置header头信息,不要让浏览器缓存当前页面(兼容多种浏览器的头信息)
header("Cache-Control:no-cache");
header("Pragma:no-cache");
header("Expires:-1");
$fp = fopen("./07.txt","a");
fwrite($fp,"beijing");
fclose($fp);