Re: PHP 4.0 Bug #8017: PHP ignores "If-Modified-Since" headers

From: Date: Wed, 29 Nov 2000 16:15:13 +0000
Subject: Re: PHP 4.0 Bug #8017: PHP ignores "If-Modified-Since" headers
References: 1  Groups: php.dev 
Request: Send a blank email to php-dev+get-39595@lists.php.net to get a copy of this message
Hi, > JR>> I understand that I could use an ETAG or manually parse the > JR>> If-Modified-Since header myself, but it seems like PHP should > JR>> handle If-Modified-Since itself. After all, a very simple shell > JR>> script like the one > > How exactly should PHP do that? The very same way CGI does, I would guess. Sorry, but am I missing something here -- why can't PHP work the same way as a CGI script in that regard? > How PHP knows if yo data that you prepare > in the script (if it would be just a static page, you won't make it > dynamic, right) has modified since given date? PHP has no prophecy > extension to do such things. The way it would work is very simple -- PHP, from how I understand it, has two phases, first where it collects the headers, and then where it outputs the body. At the moment where it starts to output the body, it should compare the Last-Modified header outputted by the script (if any) against If-Modified-Since. If (Last-Modified > If-Modified-Since), it proceeds normally and sends back a 200 code. If (Last-Modified <= If-Modified-Since), it would not output any body -- ignoring all "echo"s in the script and further HTML in the document. The script, however, continues to execute normally, completely oblivious that no body is being sent out. I'm not a PHP source hacker (yet) so I'm not sure how difficult/easy this would be to implement in PHP. But surely it *can* be done... > JR>> but that sent back a 304 code which included a Content-Type header -- a > JR>> violation of the HTTP spec. (HTTP says 304 responses "must be returned > JR>> without any message-body".) > > So do not sent the body. And Content-type is not a body - it's a header. Content-Type implies there is a body, which I suspect could confuse some browsers. I'll again quote from the HTTP 1.1 spec: "When an entity-body is included with a message, the data type of that body is determined via the header fields Content-Type and Content-Encoding." Also Apache has special code in it to specificly mask out certain headers when sending back a 304 response. From http_protocol.c: /* We need to special-case the handling of 204 and 304 responses, * since they have specific HTTP requirements and do not include a * message body. Note that being assbackwards here is not an option. */ Jordan Russell

« previous php.dev (#39595) next »