public class CacheConfig extends Object implements Cloneable
Java Beans-style configuration for a CachingHttpClient. Any class
 in the caching module that has configuration options should take a
 CacheConfig argument in one of its constructors. A
 CacheConfig instance has sane and conservative defaults, so the
 easiest way to specify options is to get an instance and then set just
 the options you want to modify from their defaults.
N.B. This class is only for caching-specific configuration; to
 configure the behavior of the rest of the client, configure the
 HttpClient used as the "backend"
 for the CachingHttpClient.
Cache configuration can be grouped into the following categories:
Cache size. If the backend storage supports these limits, you
 can specify the maximum number of
 cache entries as well as the maximum cacheable response body size.
Public/private caching. By default, the caching module considers
 itself to be a shared (public) cache, and will not, for example, cache
 responses to requests with Authorization headers or responses
 marked with Cache-Control: private. If, however, the cache
 is only going to be used by one logical "user" (behaving similarly to a
 browser cache), then you will want to turn off the shared cache setting.
303 caching. RFC2616 explicitly disallows caching 303 responses;
 however, the HTTPbis working group says they can be cached
 if explicitly indicated in the response headers and permitted by the request method.
 (They also indicate that disallowing 303 caching is actually an unintended
 spec error in RFC2616).
 This behavior is off by default, to err on the side of a conservative
 adherence to the existing standard, but you may want to
 enable it.
 
Weak ETags on PUT/DELETE If-Match requests. RFC2616 explicitly
 prohibits the use of weak validators in non-GET requests, however, the
 HTTPbis working group says while the limitation for weak validators on ranged
 requests makes sense, weak ETag validation is useful on full non-GET
 requests; e.g., PUT with If-Match. This behavior is off by default, to err on
 the side of a conservative adherence to the existing standard, but you may
 want to enable it.
 
Heuristic caching. Per RFC2616, a cache may cache certain cache
 entries even if no explicit cache control headers are set by the origin.
 This behavior is off by default, but you may want to turn this on if you
 are working with an origin that doesn't set proper headers but where you
 still want to cache the responses. You will want to enable heuristic caching,
 then specify either a default freshness lifetime and/or a fraction of the time since
 the resource was last modified. See Sections
 
 13.2.2 and 
 13.2.4 of the HTTP/1.1 RFC for more details on heuristic caching.
Background validation. The cache module supports the
 stale-while-revalidate directive of
 RFC5861, which allows
 certain cache entry revalidations to happen in the background. You may
 want to tweak the settings for the minimum and maximum number of background
 worker threads, as well as the maximum time they
 can be idle before being reclaimed. You can also control the size of the queue used for
 revalidations when there aren't enough workers to keep up with demand.
| Modifier and Type | Class and Description | 
|---|---|
| static class  | CacheConfig.Builder | 
| Modifier and Type | Field and Description | 
|---|---|
| static CacheConfig | DEFAULT | 
| static boolean | DEFAULT_303_CACHING_ENABLEDDefault setting for 303 caching | 
| static int | DEFAULT_ASYNCHRONOUS_WORKER_IDLE_LIFETIME_SECSDefault maximum idle lifetime for a background revalidation thread
 before it gets reclaimed. | 
| static int | DEFAULT_ASYNCHRONOUS_WORKERS_COREDefault minimum number of worker threads to allow for background
 revalidations resulting from the stale-while-revalidate directive. | 
| static int | DEFAULT_ASYNCHRONOUS_WORKERS_MAXDefault number of worker threads to allow for background revalidations
 resulting from the stale-while-revalidate directive. | 
| static boolean | DEFAULT_HEURISTIC_CACHING_ENABLEDDefault setting for heuristic caching | 
| static float | DEFAULT_HEURISTIC_COEFFICIENTDefault coefficient used to heuristically determine freshness
 lifetime from the Last-Modified time of a cache entry. | 
| static long | DEFAULT_HEURISTIC_LIFETIMEDefault lifetime in seconds to be assumed when we cannot calculate
 freshness heuristically. | 
| static int | DEFAULT_MAX_CACHE_ENTRIESDefault setting for the maximum number of cache entries
 that will be retained. | 
| static int | DEFAULT_MAX_OBJECT_SIZE_BYTESDefault setting for the maximum object size that will be
 cached, in bytes. | 
| static int | DEFAULT_MAX_UPDATE_RETRIESDefault setting for the number of retries on a failed
 cache update | 
| static int | DEFAULT_REVALIDATION_QUEUE_SIZEDefault maximum queue length for background revalidation requests. | 
| static boolean | DEFAULT_WEAK_ETAG_ON_PUTDELETE_ALLOWEDDefault setting to allow weak tags on PUT/DELETE methods | 
| Constructor and Description | 
|---|
| CacheConfig()Deprecated. 
 (4.3) use  CacheConfig.Builder. | 
| Modifier and Type | Method and Description | 
|---|---|
| protected CacheConfig | clone() | 
| static CacheConfig.Builder | copy(CacheConfig config) | 
| static CacheConfig.Builder | custom() | 
| int | getAsynchronousWorkerIdleLifetimeSecs()Returns the current maximum idle lifetime in seconds for a
 background revalidation worker thread. | 
| int | getAsynchronousWorkersCore()Returns the minimum number of threads to keep alive for background
 revalidations due to the  stale-while-revalidatedirective. | 
| int | getAsynchronousWorkersMax()Returns the maximum number of threads to allow for background
 revalidations due to the  stale-while-revalidatedirective. | 
| float | getHeuristicCoefficient()Returns lifetime coefficient used in heuristic freshness caching. | 
| long | getHeuristicDefaultLifetime()Get the default lifetime to be used if heuristic freshness calculation is
 not possible. | 
| int | getMaxCacheEntries()Returns the maximum number of cache entries the cache will retain. | 
| long | getMaxObjectSize()Returns the current maximum response body size that will be cached. | 
| int | getMaxObjectSizeBytes()Deprecated. 
 (4.2)  use  getMaxObjectSize() | 
| int | getMaxUpdateRetries()Returns the number of times to retry a cache update on failure | 
| int | getRevalidationQueueSize()Returns the current maximum queue size for background revalidations. | 
| boolean | is303CachingEnabled()Returns whether 303 caching is enabled. | 
| boolean | isHeuristicCachingEnabled()Returns whether heuristic caching is enabled. | 
| boolean | isNeverCacheHTTP10ResponsesWithQuery()Returns whether the cache will never cache HTTP 1.0 responses with a query string or not. | 
| boolean | isSharedCache()Returns whether the cache will behave as a shared cache or not. | 
| boolean | isWeakETagOnPutDeleteAllowed()Returns whether weak etags is allowed with PUT/DELETE methods. | 
| void | setAsynchronousWorkerIdleLifetimeSecs(int secs)Deprecated. 
 (4.3) use  CacheConfig.Builder. | 
| void | setAsynchronousWorkersCore(int min)Deprecated. 
 (4.3) use  CacheConfig.Builder. | 
| void | setAsynchronousWorkersMax(int max)Deprecated. 
 (4.3) use  CacheConfig.Builder. | 
| void | setHeuristicCachingEnabled(boolean heuristicCachingEnabled)Deprecated. 
 (4.3) use  CacheConfig.Builder. | 
| void | setHeuristicCoefficient(float heuristicCoefficient)Deprecated. 
 (4.3) use  CacheConfig.Builder. | 
| void | setHeuristicDefaultLifetime(long heuristicDefaultLifetimeSecs)Deprecated. 
 (4.3) use  CacheConfig.Builder. | 
| void | setMaxCacheEntries(int maxCacheEntries)Deprecated. 
 (4.3) use  CacheConfig.Builder. | 
| void | setMaxObjectSize(long maxObjectSize)Deprecated. 
 (4.3) use  CacheConfig.Builder. | 
| void | setMaxObjectSizeBytes(int maxObjectSizeBytes)Deprecated. 
 (4.2)  use  CacheConfig.Builder. | 
| void | setMaxUpdateRetries(int maxUpdateRetries)Deprecated. 
 (4.3) use  CacheConfig.Builder. | 
| void | setRevalidationQueueSize(int size)Deprecated. 
 (4.3) use  CacheConfig.Builder. | 
| void | setSharedCache(boolean isSharedCache)Deprecated. 
 (4.3) use  CacheConfig.Builder. | 
| String | toString() | 
public static final int DEFAULT_MAX_OBJECT_SIZE_BYTES
public static final int DEFAULT_MAX_CACHE_ENTRIES
public static final int DEFAULT_MAX_UPDATE_RETRIES
public static final boolean DEFAULT_303_CACHING_ENABLED
public static final boolean DEFAULT_WEAK_ETAG_ON_PUTDELETE_ALLOWED
public static final boolean DEFAULT_HEURISTIC_CACHING_ENABLED
public static final float DEFAULT_HEURISTIC_COEFFICIENT
public static final long DEFAULT_HEURISTIC_LIFETIME
public static final int DEFAULT_ASYNCHRONOUS_WORKERS_MAX
public static final int DEFAULT_ASYNCHRONOUS_WORKERS_CORE
public static final int DEFAULT_ASYNCHRONOUS_WORKER_IDLE_LIFETIME_SECS
public static final int DEFAULT_REVALIDATION_QUEUE_SIZE
public static final CacheConfig DEFAULT
@Deprecated public CacheConfig()
CacheConfig.Builder.@Deprecated public int getMaxObjectSizeBytes()
getMaxObjectSize()@Deprecated public void setMaxObjectSizeBytes(int maxObjectSizeBytes)
CacheConfig.Builder.maxObjectSizeBytes - size in bytespublic long getMaxObjectSize()
@Deprecated public void setMaxObjectSize(long maxObjectSize)
CacheConfig.Builder.maxObjectSize - size in bytespublic boolean isNeverCacheHTTP10ResponsesWithQuery()
true to not cache query string responses, false to cache if explicit cache headers are
 foundpublic int getMaxCacheEntries()
@Deprecated public void setMaxCacheEntries(int maxCacheEntries)
CacheConfig.Builder.public int getMaxUpdateRetries()
@Deprecated public void setMaxUpdateRetries(int maxUpdateRetries)
CacheConfig.Builder.public boolean is303CachingEnabled()
true if it is enabled.public boolean isWeakETagOnPutDeleteAllowed()
true if it is allowed.public boolean isHeuristicCachingEnabled()
true if it is enabled.@Deprecated public void setHeuristicCachingEnabled(boolean heuristicCachingEnabled)
CacheConfig.Builder.heuristicCachingEnabled - should be true to
   permit heuristic caching, false to disable it.public float getHeuristicCoefficient()
@Deprecated public void setHeuristicCoefficient(float heuristicCoefficient)
CacheConfig.Builder.Last-Modified
 and Date headers of a cached response during which the cached
 response will be considered heuristically fresh.heuristicCoefficient - should be between 0.0 and
   1.0.public long getHeuristicDefaultLifetime()
@Deprecated public void setHeuristicDefaultLifetime(long heuristicDefaultLifetimeSecs)
CacheConfig.Builder.Last-Modified freshness calculation if it is
 available.heuristicDefaultLifetimeSecs - is the number of seconds to
   consider a cache-eligible response fresh in the absence of other
   information. Set this to 0 to disable this style of
   heuristic caching.public boolean isSharedCache()
true for a shared cache, false for a non-
 shared (private) cache@Deprecated public void setSharedCache(boolean isSharedCache)
CacheConfig.Builder.isSharedCache - true to behave as a shared cache, false to
 behave as a non-shared (private) cache. To have the cache
 behave like a browser cache, you want to set this to false.public int getAsynchronousWorkersMax()
stale-while-revalidate directive. A
 value of 0 means background revalidations are disabled.@Deprecated public void setAsynchronousWorkersMax(int max)
CacheConfig.Builder.stale-while-revalidate directive.max - number of threads; a value of 0 disables background
 revalidations.public int getAsynchronousWorkersCore()
stale-while-revalidate directive.@Deprecated public void setAsynchronousWorkersCore(int min)
CacheConfig.Builder.stale-while-revalidate directive.min - should be greater than zero and less than or equal
   to getAsynchronousWorkersMax()public int getAsynchronousWorkerIdleLifetimeSecs()
@Deprecated public void setAsynchronousWorkerIdleLifetimeSecs(int secs)
CacheConfig.Builder.secs - idle lifetime in secondspublic int getRevalidationQueueSize()
@Deprecated public void setRevalidationQueueSize(int size)
CacheConfig.Builder.protected CacheConfig clone() throws CloneNotSupportedException
clone in class ObjectCloneNotSupportedExceptionpublic static CacheConfig.Builder custom()
public static CacheConfig.Builder copy(CacheConfig config)
Copyright © 1999–2022 The Apache Software Foundation. All rights reserved.