Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fixing the cache.revalidate parameter

  • Loading branch information...
commit 829d8ae1780c277f20fd712b0a32f9e6042b3ecc 1 parent de4fb29
@mtdowling mtdowling authored
View
6 src/Guzzle/Http/Plugin/CachePlugin.php
@@ -320,12 +320,12 @@ public function canResponseSatisfyRequest(RequestInterface $request, Response $r
// Requests can decline to revalidate against the origin server
// by setting the cache.revalidate param to one of:
- // never - To never revalidate and just use what is in cache
- // always - To always get a new copy
+ // never - To never revalidate and always contact the origin server
+ // skip - To skip revalidation and just use what is in cache
switch ($request->getParams()->get('cache.revalidate')) {
case 'never':
return false;
- case 'always':
+ case 'skip':
return true;
}
View
6 tests/Guzzle/Tests/Http/Plugin/CachePluginTest.php
@@ -319,7 +319,7 @@ public function cacheRevalidationDataProvider()
"HTTP/1.1 200 OK\r\nContent-Length: 5\r\n\r\nDatas",
"HTTP/1.1 200 OK\r\nContent-Length: 5\r\nDate: " . Guzzle::getHttpDate('now') . "\r\n\r\nDatas"
),
- // Skips revalidation because the request is accepting the cached copy
+ // Must get a fresh copy because the request is declining revalidation
array(
false,
"\r\n\r\n",
@@ -328,14 +328,14 @@ public function cacheRevalidationDataProvider()
null,
'never'
),
- // Must get a fresh copy because the request is declining revalidation
+ // Skips revalidation because the request is accepting the cached copy
array(
true,
"\r\n\r\n",
"HTTP/1.1 200 OK\r\nCache-Control: no-cache\r\nDate: " . Guzzle::getHttpDate('-3 hours') . "\r\nContent-Length: 4\r\n\r\nData",
null,
null,
- 'always'
+ 'skip'
),
// Throws an exception during revalidation
array(
Please sign in to comment.
Something went wrong with that request. Please try again.