@Contract(threading=IMMUTABLE)
class ResponseCachingPolicy
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
private static java.lang.String[] |
AUTH_CACHEABLE_PARAMS |
private static java.util.Set<java.lang.Integer> |
cacheableStatuses |
private org.apache.commons.logging.Log |
log |
private long |
maxObjectSizeBytes |
private boolean |
neverCache1_0ResponsesWithQueryString |
private boolean |
sharedCache |
private java.util.Set<java.lang.Integer> |
uncacheableStatuses |
Constructor and Description |
---|
ResponseCachingPolicy(long maxObjectSizeBytes,
boolean sharedCache,
boolean neverCache1_0ResponsesWithQueryString,
boolean allow303Caching)
Define a cache policy that limits the size of things that should be stored
in the cache to a maximum of
HttpResponse bytes in size. |
Modifier and Type | Method and Description |
---|---|
private boolean |
expiresHeaderLessOrEqualToDateHeaderAndNoCacheControl(org.apache.http.HttpResponse response) |
private boolean |
from1_0Origin(org.apache.http.HttpResponse response) |
protected boolean |
hasCacheControlParameterFrom(org.apache.http.HttpMessage msg,
java.lang.String[] params) |
protected boolean |
isExplicitlyCacheable(org.apache.http.HttpResponse response) |
protected boolean |
isExplicitlyNonCacheable(org.apache.http.HttpResponse response) |
boolean |
isResponseCacheable(org.apache.http.HttpRequest request,
org.apache.http.HttpResponse response)
Determine if the
HttpResponse gotten from the origin is a
cacheable response. |
boolean |
isResponseCacheable(java.lang.String httpMethod,
org.apache.http.HttpResponse response)
Determines if an HttpResponse can be cached.
|
private boolean |
requestProtocolGreaterThanAccepted(org.apache.http.HttpRequest req) |
private boolean |
unknownStatusCode(int status) |
private static final java.lang.String[] AUTH_CACHEABLE_PARAMS
private final long maxObjectSizeBytes
private final boolean sharedCache
private final boolean neverCache1_0ResponsesWithQueryString
private final org.apache.commons.logging.Log log
private static final java.util.Set<java.lang.Integer> cacheableStatuses
private final java.util.Set<java.lang.Integer> uncacheableStatuses
public ResponseCachingPolicy(long maxObjectSizeBytes, boolean sharedCache, boolean neverCache1_0ResponsesWithQueryString, boolean allow303Caching)
HttpResponse
bytes in size.maxObjectSizeBytes
- the size to limit items into the cachesharedCache
- whether to behave as a shared cache (true) or a
non-shared/private cache (false)neverCache1_0ResponsesWithQueryString
- true to never cache HTTP 1.0 responses with a query string, false
to cache if explicit cache headers are found.allow303Caching
- if this policy is permitted to cache 303 responsepublic boolean isResponseCacheable(java.lang.String httpMethod, org.apache.http.HttpResponse response)
httpMethod
- What type of request was this, a GET, PUT, other?response
- The origin responsetrue
if response is cacheableprivate boolean unknownStatusCode(int status)
protected boolean isExplicitlyNonCacheable(org.apache.http.HttpResponse response)
protected boolean hasCacheControlParameterFrom(org.apache.http.HttpMessage msg, java.lang.String[] params)
protected boolean isExplicitlyCacheable(org.apache.http.HttpResponse response)
public boolean isResponseCacheable(org.apache.http.HttpRequest request, org.apache.http.HttpResponse response)
HttpResponse
gotten from the origin is a
cacheable response.request
- the HttpRequest
that generated an origin hitresponse
- the HttpResponse
from the origintrue
if response is cacheableprivate boolean expiresHeaderLessOrEqualToDateHeaderAndNoCacheControl(org.apache.http.HttpResponse response)
private boolean from1_0Origin(org.apache.http.HttpResponse response)
private boolean requestProtocolGreaterThanAccepted(org.apache.http.HttpRequest req)