mlanthaler: Added support for the ETag header.

(merged from branches/gsoc)


git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@42104 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
Ingo Schommer 2007-09-16 15:54:16 +00:00
parent 994b485d63
commit cc03b293ad

View File

@ -266,7 +266,8 @@ class HTTP {
}
protected static $cache_age = 86400, $modification_date;
protected static $cache_age = 86400, $modification_date = null;
protected static $etag = null;
/**
* Set the maximum age of this page in web caches, in seconds
@ -277,7 +278,8 @@ class HTTP {
static function register_modification_date($dateString) {
$timestamp = strtotime($dateString);
if($timestamp > self::$modification_date) self::$modification_date = $timestamp;
if($timestamp > self::$modification_date)
self::$modification_date = $timestamp;
}
static function register_modification_timestamp($timestamp) {
@ -285,6 +287,10 @@ class HTTP {
self::$modification_date = $timestamp;
}
static function register_etag($etag) {
self::$etag = $etag;
}
/**
* Add the appropriate caching headers to the response
*
@ -316,6 +322,10 @@ class HTTP {
$expires = 2 * time() - self::$modification_date;
header("Expires: " . self::gmt_date($expires));
}
if(self::$etag) {
header('ETag: ' . self::$etag);
}
}
}