mirror of
https://github.com/mrclay/minify.git
synced 2025-08-23 06:02:51 +02:00
ConditionalGet.php : allows direct setting of ETag. Patch from Andy Dawson.
This commit is contained in:
@@ -75,6 +75,9 @@ class HTTP_ConditionalGet {
|
|||||||
* 'lastModifiedTime': (int) if given, both ETag AND Last-Modified headers
|
* 'lastModifiedTime': (int) if given, both ETag AND Last-Modified headers
|
||||||
* will be sent with content. This is recommended.
|
* will be sent with content. This is recommended.
|
||||||
*
|
*
|
||||||
|
* 'eTag': (string) if given, this will be used as the ETag header rather
|
||||||
|
* than values based on lastModifiedTime or contentHash.
|
||||||
|
*
|
||||||
* 'contentHash': (string) if given, only the ETag header can be sent with
|
* 'contentHash': (string) if given, only the ETag header can be sent with
|
||||||
* content (only HTTP1.1 clients can conditionally GET). The given string
|
* content (only HTTP1.1 clients can conditionally GET). The given string
|
||||||
* should be short with no quote characters and always change when the
|
* should be short with no quote characters and always change when the
|
||||||
@@ -109,16 +112,18 @@ class HTTP_ConditionalGet {
|
|||||||
$_SERVER['REQUEST_TIME'] + $spec['maxAge']
|
$_SERVER['REQUEST_TIME'] + $spec['maxAge']
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
if (isset($spec['lastModifiedTime'])) {
|
if (isset($spec['lastModifiedTime'])) {
|
||||||
// base both headers on time
|
$this->_setLastModified($spec['lastModifiedTime']);
|
||||||
$this->_setLastModified($spec['lastModifiedTime']);
|
if (isset($spec['eTag'])) { // Use it
|
||||||
$this->_setEtag($spec['lastModifiedTime'], $scope);
|
$this->_setEtag($spec['eTag'], $scope);
|
||||||
} else {
|
} else { // base both headers on time
|
||||||
// hope to use ETag
|
$this->_setEtag($spec['lastModifiedTime'], $scope);
|
||||||
if (isset($spec['contentHash'])) {
|
}
|
||||||
$this->_setEtag($spec['contentHash'], $scope);
|
} elseif (isset($spec['eTag'])) { // Use it
|
||||||
}
|
$this->_setEtag($spec['eTag'], $scope);
|
||||||
}
|
} elseif (isset($spec['contentHash'])) { // Use the hash as the ETag
|
||||||
|
$this->_setEtag($spec['contentHash'], $scope);
|
||||||
|
}
|
||||||
$this->_headers['Cache-Control'] = "max-age={$maxAge}, {$scope}, must-revalidate";
|
$this->_headers['Cache-Control'] = "max-age={$maxAge}, {$scope}, must-revalidate";
|
||||||
// invalidate cache if disabled, otherwise check
|
// invalidate cache if disabled, otherwise check
|
||||||
$this->cacheIsValid = (isset($spec['invalidate']) && $spec['invalidate'])
|
$this->cacheIsValid = (isset($spec['invalidate']) && $spec['invalidate'])
|
||||||
|
Reference in New Issue
Block a user