Class CachingExecBase
java.lang.Object
org.apache.hc.client5.http.impl.cache.CachingExecBase
- Direct Known Subclasses:
AsyncCachingExec
,CachingExec
-
Field Summary
FieldsModifier and TypeFieldDescription(package private) final CacheableRequestPolicy
(package private) final CacheConfig
(package private) final AtomicLong
(package private) final AtomicLong
(package private) final AtomicLong
private static final org.slf4j.Logger
(package private) final RequestProtocolCompliance
(package private) final ResponseCachingPolicy
(package private) final ResponseProtocolCompliance
(package private) final CachedHttpResponseGenerator
(package private) final CachedResponseSuitabilityChecker
(package private) static final boolean
(package private) final CacheValidityPolicy
-
Constructor Summary
ConstructorsConstructorDescriptionCachingExecBase
(CacheConfig config) CachingExecBase
(CacheValidityPolicy validityPolicy, ResponseCachingPolicy responseCachingPolicy, CachedHttpResponseGenerator responseGenerator, CacheableRequestPolicy cacheableRequestPolicy, CachedResponseSuitabilityChecker suitabilityChecker, ResponseProtocolCompliance responseCompliance, RequestProtocolCompliance requestCompliance, CacheConfig config) -
Method Summary
Modifier and TypeMethodDescription(package private) boolean
clientRequestsOurOptions
(org.apache.hc.core5.http.HttpRequest request) (package private) boolean
explicitFreshnessRequest
(org.apache.hc.core5.http.HttpRequest request, HttpCacheEntry entry, Instant now) (package private) SimpleHttpResponse
generateCachedResponse
(org.apache.hc.core5.http.HttpRequest request, org.apache.hc.core5.http.protocol.HttpContext context, HttpCacheEntry entry, Instant now) (package private) SimpleHttpResponse
generateGatewayTimeout
(org.apache.hc.core5.http.protocol.HttpContext context) (package private) String
generateViaHeader
(org.apache.hc.core5.http.HttpMessage msg) long
Reports the number of times that the cache successfully responded to anHttpRequest
without contacting the origin server.long
Reports the number of times that the cache contacted the origin server because it had no appropriate response cached.long
Reports the number of times that the cache was able to satisfy a response by revalidating an existing but stale cache entry.(package private) Instant
(package private) SimpleHttpResponse
getFatallyNonCompliantResponse
(org.apache.hc.core5.http.HttpRequest request, org.apache.hc.core5.http.protocol.HttpContext context) (package private) SimpleHttpResponse
handleRevalidationFailure
(org.apache.hc.core5.http.HttpRequest request, org.apache.hc.core5.http.protocol.HttpContext context, HttpCacheEntry entry, Instant now) (package private) boolean
mayCallBackend
(org.apache.hc.core5.http.HttpRequest request) (package private) void
recordCacheFailure
(org.apache.hc.core5.http.HttpHost target, org.apache.hc.core5.http.HttpRequest request) (package private) void
recordCacheHit
(org.apache.hc.core5.http.HttpHost target, org.apache.hc.core5.http.HttpRequest request) (package private) void
recordCacheMiss
(org.apache.hc.core5.http.HttpHost target, org.apache.hc.core5.http.HttpRequest request) (package private) void
recordCacheUpdate
(org.apache.hc.core5.http.protocol.HttpContext context) (package private) boolean
revalidationResponseIsTooOld
(org.apache.hc.core5.http.HttpResponse backendResponse, HttpCacheEntry cacheEntry) (package private) void
setResponseStatus
(org.apache.hc.core5.http.protocol.HttpContext context, CacheResponseStatus value) (package private) boolean
shouldSendNotModifiedResponse
(org.apache.hc.core5.http.HttpRequest request, HttpCacheEntry responseEntry) (package private) boolean
staleIfErrorAppliesTo
(int statusCode) (package private) boolean
staleResponseNotAllowed
(org.apache.hc.core5.http.HttpRequest request, HttpCacheEntry entry, Instant now) (package private) void
storeRequestIfModifiedSinceFor304Response
(org.apache.hc.core5.http.HttpRequest request, org.apache.hc.core5.http.HttpResponse backendResponse) For 304 Not modified responses, adds a "Last-Modified" header with the value of the "If-Modified-Since" header passed in the request.(package private) boolean
Reports whether thisCachingHttpClient
implementation supports byte-range requests as specified by theRange
andContent-Range
headers.(package private) SimpleHttpResponse
unvalidatedCacheHit
(org.apache.hc.core5.http.HttpRequest request, org.apache.hc.core5.http.protocol.HttpContext context, HttpCacheEntry entry)
-
Field Details
-
SUPPORTS_RANGE_AND_CONTENT_RANGE_HEADERS
static final boolean SUPPORTS_RANGE_AND_CONTENT_RANGE_HEADERS- See Also:
-
cacheHits
-
cacheMisses
-
cacheUpdates
-
viaHeaders
-
responseCachingPolicy
-
validityPolicy
-
responseGenerator
-
cacheableRequestPolicy
-
suitabilityChecker
-
responseCompliance
-
requestCompliance
-
cacheConfig
-
LOG
private static final org.slf4j.Logger LOG
-
-
Constructor Details
-
CachingExecBase
CachingExecBase(CacheValidityPolicy validityPolicy, ResponseCachingPolicy responseCachingPolicy, CachedHttpResponseGenerator responseGenerator, CacheableRequestPolicy cacheableRequestPolicy, CachedResponseSuitabilityChecker suitabilityChecker, ResponseProtocolCompliance responseCompliance, RequestProtocolCompliance requestCompliance, CacheConfig config) -
CachingExecBase
CachingExecBase(CacheConfig config)
-
-
Method Details
-
getCacheHits
public long getCacheHits()Reports the number of times that the cache successfully responded to anHttpRequest
without contacting the origin server.- Returns:
- the number of cache hits
-
getCacheMisses
public long getCacheMisses()Reports the number of times that the cache contacted the origin server because it had no appropriate response cached.- Returns:
- the number of cache misses
-
getCacheUpdates
public long getCacheUpdates()Reports the number of times that the cache was able to satisfy a response by revalidating an existing but stale cache entry.- Returns:
- the number of cache revalidations
-
getFatallyNonCompliantResponse
SimpleHttpResponse getFatallyNonCompliantResponse(org.apache.hc.core5.http.HttpRequest request, org.apache.hc.core5.http.protocol.HttpContext context) - Since:
- 5.2
-
recordCacheMiss
void recordCacheMiss(org.apache.hc.core5.http.HttpHost target, org.apache.hc.core5.http.HttpRequest request) -
recordCacheHit
void recordCacheHit(org.apache.hc.core5.http.HttpHost target, org.apache.hc.core5.http.HttpRequest request) -
recordCacheFailure
void recordCacheFailure(org.apache.hc.core5.http.HttpHost target, org.apache.hc.core5.http.HttpRequest request) -
recordCacheUpdate
void recordCacheUpdate(org.apache.hc.core5.http.protocol.HttpContext context) -
generateCachedResponse
SimpleHttpResponse generateCachedResponse(org.apache.hc.core5.http.HttpRequest request, org.apache.hc.core5.http.protocol.HttpContext context, HttpCacheEntry entry, Instant now) throws ResourceIOException - Throws:
ResourceIOException
-
handleRevalidationFailure
SimpleHttpResponse handleRevalidationFailure(org.apache.hc.core5.http.HttpRequest request, org.apache.hc.core5.http.protocol.HttpContext context, HttpCacheEntry entry, Instant now) throws IOException - Throws:
IOException
-
generateGatewayTimeout
-
unvalidatedCacheHit
SimpleHttpResponse unvalidatedCacheHit(org.apache.hc.core5.http.HttpRequest request, org.apache.hc.core5.http.protocol.HttpContext context, HttpCacheEntry entry) throws IOException - Throws:
IOException
-
staleResponseNotAllowed
boolean staleResponseNotAllowed(org.apache.hc.core5.http.HttpRequest request, HttpCacheEntry entry, Instant now) -
mayCallBackend
boolean mayCallBackend(org.apache.hc.core5.http.HttpRequest request) -
explicitFreshnessRequest
boolean explicitFreshnessRequest(org.apache.hc.core5.http.HttpRequest request, HttpCacheEntry entry, Instant now) -
generateViaHeader
-
setResponseStatus
void setResponseStatus(org.apache.hc.core5.http.protocol.HttpContext context, CacheResponseStatus value) -
supportsRangeAndContentRangeHeaders
boolean supportsRangeAndContentRangeHeaders()Reports whether thisCachingHttpClient
implementation supports byte-range requests as specified by theRange
andContent-Range
headers.- Returns:
true
if byte-range requests are supported
-
getCurrentDate
Instant getCurrentDate() -
clientRequestsOurOptions
boolean clientRequestsOurOptions(org.apache.hc.core5.http.HttpRequest request) -
revalidationResponseIsTooOld
boolean revalidationResponseIsTooOld(org.apache.hc.core5.http.HttpResponse backendResponse, HttpCacheEntry cacheEntry) -
shouldSendNotModifiedResponse
boolean shouldSendNotModifiedResponse(org.apache.hc.core5.http.HttpRequest request, HttpCacheEntry responseEntry) -
staleIfErrorAppliesTo
boolean staleIfErrorAppliesTo(int statusCode) -
storeRequestIfModifiedSinceFor304Response
void storeRequestIfModifiedSinceFor304Response(org.apache.hc.core5.http.HttpRequest request, org.apache.hc.core5.http.HttpResponse backendResponse) For 304 Not modified responses, adds a "Last-Modified" header with the value of the "If-Modified-Since" header passed in the request. This header is required to be able to reuse match the cache entry for subsequent requests but as defined in http specifications it is not included in 304 responses by backend servers. This header will not be included in the resulting response.
-