Class ResponseCachingPolicy
java.lang.Object
org.apache.hc.client5.http.impl.cache.ResponseCachingPolicy
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final String[]private static final org.slf4j.Loggerprivate final longprivate final booleanprivate final boolean -
Constructor Summary
ConstructorsConstructorDescriptionResponseCachingPolicy(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 ofHttpResponsebytes in size. -
Method Summary
Modifier and TypeMethodDescriptionprivate booleanexpiresHeaderLessOrEqualToDateHeaderAndNoCacheControl(org.apache.hc.core5.http.HttpResponse response) private booleanfrom1_0Origin(org.apache.hc.core5.http.HttpResponse response) protected booleanhasCacheControlParameterFrom(org.apache.hc.core5.http.HttpMessage msg, String[] params) protected booleanisExplicitlyCacheable(org.apache.hc.core5.http.HttpResponse response) protected booleanisExplicitlyNonCacheable(org.apache.hc.core5.http.HttpResponse response) booleanisResponseCacheable(String httpMethod, org.apache.hc.core5.http.HttpResponse response) Determines if an HttpResponse can be cached.booleanisResponseCacheable(org.apache.hc.core5.http.HttpRequest request, org.apache.hc.core5.http.HttpResponse response) Determine if theHttpResponsegotten from the origin is a cacheable response.private booleanunknownStatusCode(int status)
-
Field Details
-
AUTH_CACHEABLE_PARAMS
-
CACHEABLE_STATUS_CODES
-
LOG
private static final org.slf4j.Logger LOG -
maxObjectSizeBytes
private final long maxObjectSizeBytes -
neverCache1_0ResponsesWithQueryString
private final boolean neverCache1_0ResponsesWithQueryString -
uncacheableStatusCodes
-
-
Constructor Details
-
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 ofHttpResponsebytes 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 Details
-
isResponseCacheable
public boolean isResponseCacheable(String httpMethod, org.apache.hc.core5.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:
trueif response is cacheable
-
unknownStatusCode
private boolean unknownStatusCode(int status) -
isExplicitlyNonCacheable
protected boolean isExplicitlyNonCacheable(org.apache.hc.core5.http.HttpResponse response) -
hasCacheControlParameterFrom
protected boolean hasCacheControlParameterFrom(org.apache.hc.core5.http.HttpMessage msg, String[] params) -
isExplicitlyCacheable
protected boolean isExplicitlyCacheable(org.apache.hc.core5.http.HttpResponse response) -
isResponseCacheable
public boolean isResponseCacheable(org.apache.hc.core5.http.HttpRequest request, org.apache.hc.core5.http.HttpResponse response) Determine if theHttpResponsegotten from the origin is a cacheable response.- Parameters:
request- theHttpRequestthat generated an origin hitresponse- theHttpResponsefrom the origin- Returns:
trueif response is cacheable
-
expiresHeaderLessOrEqualToDateHeaderAndNoCacheControl
private boolean expiresHeaderLessOrEqualToDateHeaderAndNoCacheControl(org.apache.hc.core5.http.HttpResponse response) -
from1_0Origin
private boolean from1_0Origin(org.apache.hc.core5.http.HttpResponse response)
-