【问题标题】:header nocache not working as expected标头 nocache 未按预期工作
【发布时间】:2012-06-11 19:22:26
【问题描述】:

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

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

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

为什么这不起作用?

【问题讨论】:

  • 内容长度:0 ?空白页?
  • 尝试在第一个 Cache-Control 中附加 , max-age=0"

标签: php header browser-cache


【解决方案1】:

我刚刚在这里用 firefox 和 chrome 进行了测试(以防万一),它似乎可以正常工作!

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

http://cl.ly/041H1h1s1Q1P433W1m3Q

http://cl.ly/0o2B2I1a2N1I0N101E2w

我的猜测:也许您的 http 服务器或 php 版本存在某种错误。所以也许,您应该尝试更新两者或使用另一个 http 服务器进行测试。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2022-01-22
    • 2018-08-15
    • 1970-01-01
    • 2021-12-27
    • 1970-01-01
    • 1970-01-01
    • 2017-12-29
    相关资源
    最近更新 更多