|
Posted by Janwillem Borleffs on 10/31/43 11:23
Chris wrote:
> is there a HTTP-compliant implementation of If-Modified-Since-,
> If-Match, If-None-Match, If-Range and so on?
>
> I want my PHP-script to act exactly as if it was a static HTML-page
> delivered directly from Apache.
>
> I think this isn't easy to implement, especially if you take also
> weak and strong validators into account.
>
To implement support for the if-modified-since header and when running
Apache, you would put something like the following on top of your page:
$request = array_change_key_case(apache_request_headers(), CASE_LOWER);
if (isset($request['if-modified-since'])) {
if (filemtime(__FILE__) > strtotime($request['if-modified-since'])) {
header("HTTP/1.1 304 Not Modified");
exit;
}
}
The key here is the apache_request_headers() function, which is used to
parse the request headers.
JW
Navigation:
[Reply to this message]
|