mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
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:
parent
994b485d63
commit
cc03b293ad
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user