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

From: Date: Wed, 29 Nov 2000 03:19:06 +0000
Subject: Re: PHP 4.0 Bug #8017: PHP ignores "If-Modified-Since" headers
Groups: php.dev 
Request: Send a blank email to php-dev+get-39443@lists.php.net to get a copy of this message
Hi Jordan, The ETAG is returned in $HTTP_IF_NONE_MATCH and id send Header("Status: 304 Not Modified"); to the browser and terminates the script with an exit command if data is not modified. That works fo me. This will also work if the browser is configured to check for new versions on every visit. I might mention that we also uses header to set expiredate back in time to force the browser to check on every visit, no mater the browser settings. If the webserver did cache the page, how would you get new content displayed in the situation where the script was untouched but data was modified in the database. I still dont see this as a bug. - Frank >Hi, > >I understand that I could use an ETAG or manually parse the >If-Modified-Since header myself, but it seems like PHP should handle >If-Modified-Since itself. After all, a very simple shell script like the one >I posted below handles it properly (i.e. returns 304 codes), and "sh" isn't >even designed for HTTP like PHP is! It is for that reason I filed this issue >as a bug report. > >If I have no other choice but to manually send back a 304 code myself, what >is the proper way to do it? I tried: > >Header ("HTTP/1.0 304 Not Modified"); > >but that sent back a 304 code which included a Content-Type header -- a >violation of the HTTP spec. (HTTP says 304 responses "must be returned >without any message-body".) > >Jordan Russell > >----- Original Message ----- >From: "Frank M. Kromann" <fmk@swwwing.com> >To: <jr-php@quo.to> >Cc: <php-dev@lists.php.net> >Sent: Tuesday, November 28, 2000 8:42 PM >Subject: Re: [PHP-DEV] PHP 4.0 Bug #8017: PHP ignores "If-Modified-Since" >headers > > >> Hi All, >> >> I use "Last-Modified" and an ETAG header with my php scripts. I use the >ETAG header to check if data has been modified in the database, if not I >have the php script return a HTTP 304 header alowing the browser to use the >page from cache. >> This works fine for me. >> >> I dont think anye webserver would be able to detect this for all php >scrpts and keep the contents in cache (dynamic web pages does not exist on >the harddisk). >> >> - Frank >> >> >From: jr-php@quo.to >> >Operating system: Linux >> >PHP version: 4.0.3pl1 >> >PHP Bug Type: Apache related >> >Bug description: PHP ignores "If-Modified-Since" headers >> > >> >PHP: 4.0.3p1 >> >Apache: 1.3.14 >> >Browser: IE 5.5 SP1 >> > >> >Because I want my PHP pages to be cached, my PHP script sends out a >Last-Modified header (entire code follows): >> > >> ><?php >> >Header ("Last-Modified: Mon, 27 Nov 2000 00:00:00 GMT"); >> >?> >> >Test... >> > >> >One would think that this would be enough to get a web browser to cache >the page, but evidently it is not. Examining my web server's access log >shows that each time the page is subsequently requested (e.g. by pressing >Refresh), it sends back a "200 OK" response code instead of a "304 Not >Modified" as it should. In other words, the server is sending back a fresh >copy of the page every time. >> > >> >However, if I do a similar thing using a CGI script, the server *does* >send back "304" codes as it should (entire code follows): >> > >> >#!/bin/sh >> >echo "Last-Modified: Mon, 27 Nov 2000 00:00:00 GMT" >> >echo "Content-Type: text/html" >> >echo "" >> >echo "Test..." >> > >> >In both cases, an "If-Modified-Since" header is being sent to the server. >Yet the PHP script appears to ignore it completely and send a fresh page, >while the very simple CGI shell script doesn't. >> > >> >P.S. At the bottom of this are transcripts of the HTTP requests for the >PHP & CGI scripts. Notice how PHP sends back a fresh page even though the >If-Modified-Since date is the same as the Last-Modified date. >> > >> >P.P.S. I just noticed that this problem affects PHP's own web site too! >The page http://www.php.net/ returns a Last-Modified header, but >browsers >receive a fresh copy of the page every time since If-Modified-Since is >ignored. >> > >> > >> >--- PHP script --- >> > >> >GET /test.php HTTP/1.0 >> >If-Modified-Since: Mon, 27 Nov 2000 00:00:00 GMT >> > >> >HTTP/1.1 200 OK >> >Date: Mon, 27 Nov 2000 20:41:29 GMT >> >Server: Apache/1.3.14 (Unix) PHP/4.0.3pl1 >> >X-Powered-By: PHP/4.0.3pl1 >> >Last-Modified: Mon, 27 Nov 2000 00:00:00 GMT >> >Connection: close >> >Content-Type: text/html >> > >> >Test... >> > >> > >> >--- CGI shell script --- >> > >> >GET /cgi-bin/test.cgi HTTP/1.0 >> >If-Modified-Since: Mon, 27 Nov 2000 00:00:00 GMT >> > >> >HTTP/1.1 304 Not Modified >> >Date: Mon, 27 Nov 2000 20:41:46 GMT >> >Server: Apache/1.3.14 (Unix) PHP/4.0.3pl1 >> >Connection: close >> > >> > >> >-- >> >Edit Bug report at: >> >http://bugs.php.net/?id=8017&edit=1 >> > >> > >> > >> >-- >> >PHP Development Mailing List >> ><http://www.php.net/> >> >To unsubscribe, e-mail: php-dev-unsubscribe@lists.php.net >> >For additional commands, e-mail: php-dev-help@lists.php.net >> >To contact the list administrators, e-mail: php-list-admin@lists.php.net >> > >> > >> > >> >> >> > > >

« previous php.dev (#39443) next »