- Fixed cache's handling of HTTP headers (passed all 9 unit tests)
parent
0c3cc7b487
commit
46e43ebed1
|
@ -1173,17 +1173,18 @@ function drupal_page_header() {
|
||||||
$etag = '"'. md5($date) .'"';
|
$etag = '"'. md5($date) .'"';
|
||||||
|
|
||||||
// Check http headers:
|
// Check http headers:
|
||||||
$modified_since = isset($_SERVER["HTTP_IF_MODIFIED_SINCE"]) ? $_SERVER["HTTP_IF_MODIFIED_SINCE"] == $date : false;
|
$modified_since = isset($_SERVER["HTTP_IF_MODIFIED_SINCE"]) ? $_SERVER["HTTP_IF_MODIFIED_SINCE"] == $date : NULL
|
||||||
$none_match = isset($_SERVER["HTTP_IF_NONE_MATCH"]) ? $_SERVER["HTTP_IF_NONE_MATCH"] == $etag : false;
|
$none_match = isset($_SERVER["HTTP_IF_NONE_MATCH"]) ? $_SERVER["HTTP_IF_NONE_MATCH"] == $etag : NULL;
|
||||||
|
|
||||||
// Send appropriate response:
|
// The type checking here is very important, be careful when changing entries.
|
||||||
//header("Last-Modified: $date");
|
if (($modified_since !== NULL || $none_match !== NULL) && $modified_since !== false && $none_match !== false) {
|
||||||
header("ETag: $etag");
|
|
||||||
if ($modified_since && $none_match) {
|
|
||||||
header("HTTP/1.0 304 Not Modified");
|
header("HTTP/1.0 304 Not Modified");
|
||||||
exit();
|
exit();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Send appropriate response:
|
||||||
|
header("Last-Modified: $date");
|
||||||
|
header("ETag: $etag");
|
||||||
print $cache->data;
|
print $cache->data;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
Loading…
Reference in New Issue