forked from lino/radar-wp
Initial import.
This commit is contained in:
commit
86383280c9
428 changed files with 68738 additions and 0 deletions
32
vendor/guzzle/plugin-cache/Guzzle/Plugin/Cache/DefaultCanCacheStrategy.php
vendored
Normal file
32
vendor/guzzle/plugin-cache/Guzzle/Plugin/Cache/DefaultCanCacheStrategy.php
vendored
Normal file
|
@ -0,0 +1,32 @@
|
|||
<?php
|
||||
|
||||
namespace Guzzle\Plugin\Cache;
|
||||
|
||||
use Guzzle\Http\Message\RequestInterface;
|
||||
use Guzzle\Http\Message\Response;
|
||||
|
||||
/**
|
||||
* Default strategy used to determine of an HTTP request can be cached
|
||||
*/
|
||||
class DefaultCanCacheStrategy implements CanCacheStrategyInterface
|
||||
{
|
||||
public function canCacheRequest(RequestInterface $request)
|
||||
{
|
||||
// Only GET and HEAD requests can be cached
|
||||
if ($request->getMethod() != RequestInterface::GET && $request->getMethod() != RequestInterface::HEAD) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Never cache requests when using no-store
|
||||
if ($request->hasHeader('Cache-Control') && $request->getHeader('Cache-Control')->hasDirective('no-store')) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public function canCacheResponse(Response $response)
|
||||
{
|
||||
return $response->isSuccessful() && $response->canCache();
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue