标头nocache没有按预期工作

时间:2012-06-11 19:22:27

标签: php header browser-cache

我网站脚本上的标题包含以下内容:

header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");

在任何输出/空格之前调用这些行。

这是我的实时页眉查看器中显示的内容:

POST /includes/whosonline.php HTTP/1.1
Host: mysite.org
User-Agent: Linux/Firefox 11
Accept: text/javascript, text/html, application/xml, text/xml, */*
Accept-Language: en-us,en;q=0.5
Accept-Encoding: gzip, deflate
Connection: keep-alive
X-Requested-With: XMLHttpRequest
X-Prototype-Version: 1.6.0.2
Content-Type: application/x-www-form-urlencoded; charset=UTF-8
Referer: https://mysite.org?id=123
Content-Length: 0
Cookie: [cookie stuff removed]
Pragma: no-cache
Cache-Control: no-cache

请注意,脚本的标头指定浏览器不缓存页面。到期日期在当前日期之前。

为什么这不起作用?

1 个答案:

答案 0 :(得分:1)

我刚刚使用firefox和chrome进行了测试(以防万一),它似乎正在运行!

  • 操作系统:Mac OS X Lion
  • 服务器:Nginx 1.2
  • PHP:5.3

http://cl.ly/041H1h1s1Q1P433W1m3Q

http://cl.ly/0o2B2I1a2N1I0N101E2w

我的猜测:也许你的http服务器或php版本有某种bug。所以,也许你应该尝试更新它们或用另一个http服务器进行测试。