Re: PHP 4.0 Bug #8017: PHP ignores "If-Modified-Since" headers
| From: | Jordan Russell | Date: | Wed, 29 Nov 2000 16:27:34 +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-39597@lists.php.net to get a copy of this message | ||
Hi Frank,
> >Again, I still think PHP should automatically handle If-Modified-Since
> >itself, by sending back a 304 response code and no content if the PHP
script
> >sends out a Modified header which is less than or equal to
> >If-Modified-Since. As I've said, CGI scripts written in non-web languages
> >such as Perl or sh do this automatically (i.e. with *no* special coding
at
> >all), so IMHO it only stands to reason that a high-level language like
PHP
> >should too.
> >
>
> How can the PHP engine determine wheter or not the content of a script has
changed ?
By examining the Last-Modified header the script sends out. I'm not
proposing that PHP "read the mind" of the script. Instead, very simply, if a
Last-Modified header sent out by the script is less than or equal to
If-Modified-Since, PHP should send out a 304 code and no body. This is in
accordance with the HTTP spec. (See my response to Stanislav Malyshev's mail
where I explain this in a bit more detail.)
> The script can contain data from a database or any other source. This
information can
> only come from the script. The client sends a header with information on
last modified
> the php engine can only compare this to the file date of the script but
that will not be
> valid if the data in the database has changed.
The PHP engine could compare the If-Modified-Since header against the
Last-Modified header that the script sends out. In pseudo-code, it would
work something like this:
if (php script sent a Last-Modified header) {
if (If-Modified-Since exists && Last-Modified > If-Modified-Since) {
send out a 304 code;
don't output any body; //...but let the script keep on executing
return;
}
}
Does that make sense?
> I would say the same goes for shell scripts. How would the server or the
script know about
> changes in the conten if it was not checked by the script ?
Neither PHP, the web server, nor the web browser should be concerned about
changes in the content. All PHP should be doing is checking the
Last-Modified date against the If-Modified-Since date to see if it should be
sending out a body or not.
Jordan Russell