Class ResponseCachingPolicy
- java.lang.Object
-
- org.apache.http.impl.client.cache.ResponseCachingPolicy
-
@Contract(threading=IMMUTABLE) class ResponseCachingPolicy extends java.lang.Object
Determines if an HttpResponse can be cached.- Since:
- 4.1
-
-
Field Summary
Fields Modifier and Type Field 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 Summary
Constructors Constructor 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 ofHttpResponse
bytes in size.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method 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(java.lang.String httpMethod, org.apache.http.HttpResponse response)
Determines if an HttpResponse can be cached.boolean
isResponseCacheable(org.apache.http.HttpRequest request, org.apache.http.HttpResponse response)
Determine if theHttpResponse
gotten from the origin is a cacheable response.private boolean
requestProtocolGreaterThanAccepted(org.apache.http.HttpRequest req)
private boolean
unknownStatusCode(int status)
-
-
-
Field Detail
-
AUTH_CACHEABLE_PARAMS
private static final java.lang.String[] AUTH_CACHEABLE_PARAMS
-
maxObjectSizeBytes
private final long maxObjectSizeBytes
-
sharedCache
private final boolean sharedCache
-
neverCache1_0ResponsesWithQueryString
private final boolean neverCache1_0ResponsesWithQueryString
-
log
private final org.apache.commons.logging.Log log
-
cacheableStatuses
private static final java.util.Set<java.lang.Integer> cacheableStatuses
-
uncacheableStatuses
private final java.util.Set<java.lang.Integer> uncacheableStatuses
-
-
Constructor Detail
-
ResponseCachingPolicy
public 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 ofHttpResponse
bytes in size.- Parameters:
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 response
-
-
Method Detail
-
isResponseCacheable
public boolean isResponseCacheable(java.lang.String httpMethod, org.apache.http.HttpResponse response)
Determines if an HttpResponse can be cached.- Parameters:
httpMethod
- What type of request was this, a GET, PUT, other?response
- The origin response- Returns:
true
if response is cacheable
-
unknownStatusCode
private boolean unknownStatusCode(int status)
-
isExplicitlyNonCacheable
protected boolean isExplicitlyNonCacheable(org.apache.http.HttpResponse response)
-
hasCacheControlParameterFrom
protected boolean hasCacheControlParameterFrom(org.apache.http.HttpMessage msg, java.lang.String[] params)
-
isExplicitlyCacheable
protected boolean isExplicitlyCacheable(org.apache.http.HttpResponse response)
-
isResponseCacheable
public boolean isResponseCacheable(org.apache.http.HttpRequest request, org.apache.http.HttpResponse response)
Determine if theHttpResponse
gotten from the origin is a cacheable response.- Parameters:
request
- theHttpRequest
that generated an origin hitresponse
- theHttpResponse
from the origin- Returns:
true
if response is cacheable
-
expiresHeaderLessOrEqualToDateHeaderAndNoCacheControl
private boolean expiresHeaderLessOrEqualToDateHeaderAndNoCacheControl(org.apache.http.HttpResponse response)
-
from1_0Origin
private boolean from1_0Origin(org.apache.http.HttpResponse response)
-
requestProtocolGreaterThanAccepted
private boolean requestProtocolGreaterThanAccepted(org.apache.http.HttpRequest req)
-
-