php - Apache 在发送 304 时忽略 PHP header

标签 php apache http http-headers

当我在 Apache + mod_php5 中设置自定义 header 时,效果很好:

header('Foo: Bar');

但是当我尝试此操作时同时还发送了 304 Not Modified 响应, header 似乎已被 apache 删除(连同 X-Powered-By 和其他标准 header )。

header('HTTP/1.1 304 No Content');
header('Foo: Bar');

有谁知道如何解决这个问题?

最佳答案

这不是回答问题吗?

If the conditional GET used a strong cache validator (see section 13.3.3), the response SHOULD NOT include other entity-headers. Otherwise (i.e., the conditional GET used a weak validator), the response MUST NOT include other entity-headers; this prevents inconsistencies between cached entity-bodies and updated headers.

来自 http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.3.5

关于php - Apache 在发送 304 时忽略 PHP header ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6491419/

相关文章:

java - Apache HttpComponents HttpClient 超时

javascript - jquery:检测动态生成的输入的变化

PHP PDO : how does re-preparing a statement affect performance

php - 检查数据是否在另一个表中

php - 登录 Apache 后如何将凭据传递给 PHP 脚本

php - Windows:在部署到 Amazon Beanstalk 之前设置 PHP 文件权限

apache - 我正在使用 Hadoop 2.7.2 安装 Hive 2.0.0

asp.net - 将数据发布到 ASP.NET 应用程序

php - 在 mysql-php 中出现语法错误。您的 SQL 语法有误;

api - 我应该使用自定义 header 还是用户代理 header 将设备信息发送到服务器