[英]What is removing my headers in PHP/Apache2?
我正在使用PHP 5.3和Apache 2.0來提供一個腳本,該腳本向輸出添加了許多標頭:
header('HTTP/1.1 200 OK');
header("Content-Type: application/json");
header("Last-Modified: $lastmode"); // $lastmod = Tue, 01 Mar 2011 14:56:22 +0000
header("Etag: $etag"); // Etag = 5da02274fcad09a55f4d74467f66a864
現在,除了Last-Modified
和Etag
之外,所有標頭都通過。 在我的httpd.conf中,我具有以下內容:
Header unset Cache-Control
Header unset Pragma
但是在我的回應中,我得到:
HTTP/1.1 200 OK
Date: Tue, 01 Mar 2011 16:49:10 GMT
Server: Apache/2.2.14 (EL) mod_ssl/2.2.14 OpenSSL/0.9.8e-fips-rhel5
Keep-Alive: timeout=15, max=8000
Connection: Keep-Alive
Transfer-Encoding: chunked
Content-Type: application/json
Expires: 0
Cache-Control: no-cache
我的Last-Modified
和Etag
標頭不見了,我們在它們的位置有Cache-Control
和Expires
。
我還應該提到我已禁用mod_expires
無濟於事。 我現在正在拔頭發,因為無論我做什么,標題都根本不存在。 有什么可能導致它們被刪除?
謝謝,J
更新:看來PHP關閉后Apache正在添加其他頭文件,我認為它也正在刪除我在上面設置的頭文件。 在PHP中注冊關閉功能並調用apache_response_headers
顯示:
Pragma=
Expires=
Etag=5da02274fcad09a55f4d74467f66a864
Last-Modified=Tue, 01 Mar 2011 14:56:22 +0000
Keep-Alive=timeout=15, max=8000
Connection=Keep-Alive
Transfer-Encoding=chunked
Content-Type=application/json
為了回答我自己的問題,似乎我用來調試的工具使我感到悲傷。 首先是由mod_expires模塊引起的問題,但刪除該模塊沒有任何作用的原因是,我用來調試問題的代理(查爾斯)似乎在修改標頭。 一旦Charles退出循環,我的標題就在那里了!
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.