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

From: Date: Wed, 29 Nov 2000 20:20:04 +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-39624@lists.php.net to get a copy of this message
> >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. > > > > For what reson would you continue processing the script and block all output to the client ? Because having the script abruptly terminate at the moment PHP discerns that it will be returning a 304 response is probably not a good idea. Files or DBs could be left in an incomplete or inconsistent state. Plus it'd probably be easier to implement that way, if I'm not mistaken (?). But perhaps there could be a function like "body_suppressed()" which would return true if PHP is not sending back a body. In response, the script could execute finalization procedures, then call "exit;", and not waste time executing the rest of the script. > For most scripts I know the parsing of the script is more time (and cpu) consuming than actually sending content to the client. Well, not everyone has unlimited bandwidth to work with. The server may have a relatively slow link (e.g. an ISDN line). And most web hosts limit you to a certain amount of data transfer per month. When you have a client that visits a page 10 times a day, and the content never changes, the server is sending that web page 9 times more than necessary. If the script were to send a Last-Modified header, and PHP handled If-Modified-Since appropriately, the page would only be sent once to the client; subsequent requests would be pulled out of the web browser cache. Not only does this conserve bandwidth on the server end, it also makes the page come up significantly faster for the client. So it's a win-win situation for everyone. Jordan Russell

« previous php.dev (#39624) next »