Class CacheConfig.Builder
java.lang.Object
org.apache.hc.client5.http.impl.cache.CacheConfig.Builder
- Enclosing class:
CacheConfig
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate booleanprivate intprivate booleanprivate booleanprivate floatprivate org.apache.hc.core5.util.TimeValueprivate intprivate longprivate intprivate booleanprivate booleanprivate boolean -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbuild()setAllow303Caching(boolean allow303Caching) Enables or disables 303 caching.setAsynchronousWorkers(int asynchronousWorkers) Sets the maximum number of threads to allow for background revalidations due to thestale-while-revalidatedirective.setFreshnessCheckEnabled(boolean freshnessCheckEnabled) setHeuristicCachingEnabled(boolean heuristicCachingEnabled) Enables or disables heuristic caching.setHeuristicCoefficient(float heuristicCoefficient) Sets coefficient to be used in heuristic freshness caching.setHeuristicDefaultLifetime(org.apache.hc.core5.util.TimeValue heuristicDefaultLifetime) Sets default lifetime to be used if heuristic freshness calculation is not possible.setMaxCacheEntries(int maxCacheEntries) Sets the maximum number of cache entries the cache will retain.setMaxObjectSize(long maxObjectSize) Specifies the maximum response body size that will be eligible for caching.setMaxUpdateRetries(int maxUpdateRetries) Sets the number of times to retry a cache processChallenge on failuresetNeverCacheHTTP10ResponsesWithQueryString(boolean neverCacheHTTP10ResponsesWithQuery) Sets whether the cache should never cache HTTP 1.0 responses with a query string or not.setSharedCache(boolean sharedCache) Sets whether the cache should behave as a shared cache or not.setWeakETagOnPutDeleteAllowed(boolean weakETagOnPutDeleteAllowed) Allows or disallows weak etags to be used with PUT/DELETE If-Match requests.
-
Field Details
-
maxObjectSize
private long maxObjectSize -
maxCacheEntries
private int maxCacheEntries -
maxUpdateRetries
private int maxUpdateRetries -
allow303Caching
private boolean allow303Caching -
weakETagOnPutDeleteAllowed
private boolean weakETagOnPutDeleteAllowed -
heuristicCachingEnabled
private boolean heuristicCachingEnabled -
heuristicCoefficient
private float heuristicCoefficient -
heuristicDefaultLifetime
private org.apache.hc.core5.util.TimeValue heuristicDefaultLifetime -
freshnessCheckEnabled
private boolean freshnessCheckEnabled -
asynchronousWorkers
private int asynchronousWorkers -
neverCacheHTTP10ResponsesWithQuery
private boolean neverCacheHTTP10ResponsesWithQuery
-
-
Constructor Details
-
Builder
Builder()
-
-
Method Details
-
setMaxObjectSize
Specifies the maximum response body size that will be eligible for caching.- Parameters:
maxObjectSize- size in bytes
-
setMaxCacheEntries
Sets the maximum number of cache entries the cache will retain. -
setMaxUpdateRetries
Sets the number of times to retry a cache processChallenge on failure -
setAllow303Caching
Enables or disables 303 caching.- Parameters:
allow303Caching- should betrueto permit 303 caching,falseto disable it.
-
setWeakETagOnPutDeleteAllowed
Allows or disallows weak etags to be used with PUT/DELETE If-Match requests.- Parameters:
weakETagOnPutDeleteAllowed- should betrueto permit weak etags,falseto reject them.
-
setHeuristicCachingEnabled
Enables or disables heuristic caching.- Parameters:
heuristicCachingEnabled- should betrueto permit heuristic caching,falseto enable it.
-
setHeuristicCoefficient
Sets coefficient to be used in heuristic freshness caching. This is interpreted as the fraction of the time between theLast-ModifiedandDateheaders of a cached response during which the cached response will be considered heuristically fresh.- Parameters:
heuristicCoefficient- should be between0.0and1.0.
-
setHeuristicDefaultLifetime
public CacheConfig.Builder setHeuristicDefaultLifetime(org.apache.hc.core5.util.TimeValue heuristicDefaultLifetime) Sets default lifetime to be used if heuristic freshness calculation is not possible. Explicit cache control directives on either the request or origin response will override this, as will the heuristicLast-Modifiedfreshness calculation if it is available.- Parameters:
heuristicDefaultLifetime- is the number to consider a cache-eligible response fresh in the absence of other information. Set this to0to disable this style of heuristic caching.
-
setAsynchronousWorkers
Sets the maximum number of threads to allow for background revalidations due to thestale-while-revalidatedirective.- Parameters:
asynchronousWorkers- number of threads; a value of 0 disables background revalidations.
-
setNeverCacheHTTP10ResponsesWithQueryString
public CacheConfig.Builder setNeverCacheHTTP10ResponsesWithQueryString(boolean neverCacheHTTP10ResponsesWithQuery) Sets whether the cache should never cache HTTP 1.0 responses with a query string or not.- Parameters:
neverCacheHTTP10ResponsesWithQuery- true to never cache responses with a query string, false to cache if explicit cache headers are found. Set this totrueto better emulate IE, which also never caches responses, regardless of what caching headers may be present.
-
setFreshnessCheckEnabled
-
build
-