diff options
author | Dries Buytaert <dries@buytaert.net> | 2003-09-28 17:21:57 +0000 |
---|---|---|
committer | Dries Buytaert <dries@buytaert.net> | 2003-09-28 17:21:57 +0000 |
commit | b8416f613a0db27c63aa92321a5cb537beb46c54 (patch) | |
tree | 0f466df50e01cddadd2617ac110141b70740bf59 | |
parent | 069e1bb87b9971f160f8ddccfe95335986dd17e0 (diff) | |
download | brdo-b8416f613a0db27c63aa92321a5cb537beb46c54.tar.gz brdo-b8416f613a0db27c63aa92321a5cb537beb46c54.tar.bz2 |
- Made the check for If-Modified-Since and Etag headers work for non-Apache
webservers. This will, for example, improve caching on IIS. Patch by
Kjartan.
-rw-r--r-- | includes/common.inc | 24 |
1 files changed, 13 insertions, 11 deletions
diff --git a/includes/common.inc b/includes/common.inc index 64c536b43..f84aceedc 100644 --- a/includes/common.inc +++ b/includes/common.inc @@ -1046,19 +1046,21 @@ function drupal_page_header() { if (variable_get("cache", 0)) { if ($cache = page_get_cache()) { + + // Set default values: $date = gmdate("D, d M Y H:i:s", $cache->created) ." GMT"; + $etag = '"'. md5($date) .'"'; + + // Check http headers: + $modified_since = isset($_SERVER["HTTP_IF_MODIFIED_SINCE"]) ? $_SERVER["HTTP_IF_MODIFIED_SINCE"] == $date : true; + $none_match = isset($_SERVER["HTTP_IF_NONE_MATCH"]) ? $_SERVER["HTTP_IF_NONE_MATCH"] == $etag : true; + + // Send appropriate response: header("Last-Modified: $date"); - header("ETag: \"$date\""); - if (function_exists("getallheaders") && $headers = getallheaders()) { - /* - ** Notice that the above is an optional Apache-ism so for the - ** time being we don't send 304 headers when "getallheaders()" - ** is not supported (eg. on IIS webservers). - */ - if ($headers["If-Modified-Since"] == $date && $headers["If-None-Match"] == "\"$date\"") { - header("HTTP/1.0 304 Not Modified"); - exit(); - } + header("ETag: $etag"); + if ($modified_since && $none_match) { + header("HTTP/1.0 304 Not Modified"); + exit(); } print $cache->data; |