cakebook / branches / master / vendors / minify / addExplicitEtag.diff
history
Index: lib/HTTP/ConditionalGet.php
===================================================================
--- lib/HTTP/ConditionalGet.php (revision 255)
+++ lib/HTTP/ConditionalGet.php (working copy)
@@ -109,16 +109,18 @@
$_SERVER['REQUEST_TIME'] + $spec['maxAge']
);
}
- if (isset($spec['lastModifiedTime'])) {
- // base both headers on time
- $this->_setLastModified($spec['lastModifiedTime']);
- $this->_setEtag($spec['lastModifiedTime'], $scope);
- } else {
- // hope to use ETag
- if (isset($spec['contentHash'])) {
- $this->_setEtag($spec['contentHash'], $scope);
- }
- }
+ if (isset($spec['lastModifiedTime'])) {
+ $this->_setLastModified($spec['lastModifiedTime']);
+ if (isset($spec['eTag'])) { // Use it
+ $this->_setEtag($spec['eTag'], $scope);
+ } else { // base both headers on time
+ $this->_setEtag($spec['lastModifiedTime'], $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";
// invalidate cache if disabled, otherwise check
$this->cacheIsValid = (isset($spec['invalidate']) && $spec['invalidate'])
