@Immutable public class DefaultCachingPolicy extends Object implements CachingPolicy
This implementation currently supports HTTP/1.1 Cache-Control header only, no Expires etc.
| Constructor and Description |
|---|
DefaultCachingPolicy(boolean sharedCache)
Creates a new instance of
DefaultCachingPolicy without the
size limit. |
DefaultCachingPolicy(boolean sharedCache,
long maxBodySizeBytes)
Creates a new instance of
DefaultCachingPolicy with defined
size limit of responses that should be stored in the cache. |
| Modifier and Type | Method and Description |
|---|---|
protected boolean |
isCacheableMethod(org.springframework.http.HttpMethod method) |
protected boolean |
isExplicitlyCacheable(org.springframework.http.client.ClientHttpResponse response)
Whether the given response should be cached.
|
protected boolean |
isExplicitlyNonCacheable(org.springframework.http.client.ClientHttpResponse response)
Whether the given response must not be cached.
|
protected boolean |
isImplicitlyCacheableStatus(int status)
Whether the given status code can be cached implicitly, i.e.
|
protected boolean |
isResponseCacheable(org.springframework.http.client.ClientHttpResponse response) |
boolean |
isResponseCacheable(org.springframework.http.HttpRequest request,
org.springframework.http.client.ClientHttpResponse response)
Determine if the
ClientHttpResponse gotten from the origin is a
cacheable response. |
boolean |
isServableFromCache(org.springframework.http.HttpRequest request)
Determines if the given
HttpRequest is allowed to be served
from cache. |
protected boolean |
isUncacheableStatus(int status)
Whether the given status code must not be cached, even when any cache
header is specified.
|
protected boolean |
isUnknownStatus(int status)
Whether the given status code is considered to unknown and thus must not
be cached.
|
public DefaultCachingPolicy(boolean sharedCache)
DefaultCachingPolicy without the
size limit.sharedCache - Whether to behave as a shared cache (true) or a
non-shared/private cache (false).DefaultCachingPolicy(boolean, long)public DefaultCachingPolicy(boolean sharedCache,
long maxBodySizeBytes)
DefaultCachingPolicy with defined
size limit of responses that should be stored in the cache.
A private cache will not, for example, cache responses to requests with Authorization headers or responses marked with Cache-Control: private. If, however, the cache is only going to be used by one logical "user" (behaving similarly to a browser cache), then you will want to turn off the shared cache setting.
maxBodySizeBytes - The maximum content length.sharedCache - Whether to behave as a shared cache (true) or a
non-shared/private cache (false).public boolean isResponseCacheable(org.springframework.http.HttpRequest request,
org.springframework.http.client.ClientHttpResponse response)
CachingPolicyClientHttpResponse gotten from the origin is a
cacheable response.isResponseCacheable in interface CachingPolicyrequest - The request that generated an origin hit.response - The response from the origin.public boolean isServableFromCache(org.springframework.http.HttpRequest request)
CachingPolicyHttpRequest is allowed to be served
from cache.isServableFromCache in interface CachingPolicyrequest - The request to check.protected boolean isResponseCacheable(org.springframework.http.client.ClientHttpResponse response)
protected boolean isImplicitlyCacheableStatus(int status)
status - HTTP status codeprotected boolean isUncacheableStatus(int status)
status - HTTP status codeprotected boolean isUnknownStatus(int status)
status - HTTP status codeprotected boolean isCacheableMethod(org.springframework.http.HttpMethod method)
protected boolean isExplicitlyNonCacheable(org.springframework.http.client.ClientHttpResponse response)
protected boolean isExplicitlyCacheable(org.springframework.http.client.ClientHttpResponse response)
Copyright © 2014. All rights reserved.