Sending 304 - Headers are altered by apache?
| From: | jtaal at eljakim dot nl | Date: | Mon, 27 Oct 2008 18:15:36 +0000 |
| Subject: | Sending 304 - Headers are altered by apache? | ||
| Groups: | php.pear.dev | ||
| Request: | Send a blank email to pear-dev+get-50934@lists.php.net to get a copy of this message | ||
Hi all
I'm writing a pear package which contains some js/css files. Obviously the files aren't available to the webserver's webroot (I'm using apache2). I've created a script that performs a readfile on the file from the data_dir (I'm using a replace task in my package.xml).
So far all is well...
To increase performance I'm trying to support the Last-Modified and ETag headers. This triggers a browser to use their caching and even (Firefox does this) omit the HTTP call to the file!
So I have a test.php which serves an html doc with a link rel="stylesheet" href="test.php?resource=stylesheet". The latter produces a css doc.
However...
Sending the headers when I'm sending the initial data (status 200) works, I'm getting the correct Last-Modified and ETag.
The second time I'm requesting the file something weird happens:
I'm not getting all HTTP Headers that I'm expecting.
the X-Powered-By is missing as is the Last-Modified.
I'm using FirePHP, but all the Wf-... headers are absent.
The only headers I'm getting are:
HTTP/1.0 304 Not Modified
Date Mon, 27 Oct 2008 17:21:13 GMT
Server Apache/2.2.9 (Debian) PHP/5.2.6-5 with Suhosin-Patch
Connection close
Etag "a49362004946ee139eccb3d077738c44"
(I used Wireshark to tcpdump and this is indeed what happens)
Note that this only happens when I'm looking at test.php, directly looking at test.php?resource=stylesheet gives me normal, expected headers. As far as I can see the only difference between the requests is that the referer is present when using test.php
Somehow this was causing my browser to alternate between sending the If-Modified-Since/If-None-Match headers and omitting them (resulting in sending the data every two times it was requested).
When I'm testing right now I'm getting the expected result which is a 200, a 304 and my browser doesn't ask for the file anymore (pressing F5 repeatedly).
I know that the PHP process is executed, I'm logging to a file and I'm seeing the process for the specific file.
Does anyone know what is happening here?