@Contract(threading=IMMUTABLE)
class CacheValidityPolicy
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
static long |
MAX_AGE |
Constructor and Description |
---|
CacheValidityPolicy() |
Modifier and Type | Method and Description |
---|---|
protected boolean |
contentLengthHeaderMatchesActualLength(HttpCacheEntry entry)
This matters for deciding whether the cache entry is valid to serve as a
response.
|
protected long |
getAgeValue(HttpCacheEntry entry) |
protected long |
getApparentAgeSecs(HttpCacheEntry entry) |
protected long |
getContentLengthValue(HttpCacheEntry entry) |
protected long |
getCorrectedInitialAgeSecs(HttpCacheEntry entry) |
protected long |
getCorrectedReceivedAgeSecs(HttpCacheEntry entry) |
long |
getCurrentAgeSecs(HttpCacheEntry entry,
java.util.Date now) |
protected java.util.Date |
getDateValue(HttpCacheEntry entry)
Deprecated.
(4.3) use
HttpCacheEntry.getDate() . |
protected java.util.Date |
getExpirationDate(HttpCacheEntry entry) |
long |
getFreshnessLifetimeSecs(HttpCacheEntry entry) |
long |
getHeuristicFreshnessLifetimeSecs(HttpCacheEntry entry,
float coefficient,
long defaultLifetime) |
protected java.util.Date |
getLastModifiedValue(HttpCacheEntry entry) |
protected long |
getMaxAge(HttpCacheEntry entry) |
protected long |
getResidentTimeSecs(HttpCacheEntry entry,
java.util.Date now) |
protected long |
getResponseDelaySecs(HttpCacheEntry entry) |
long |
getStalenessSecs(HttpCacheEntry entry,
java.util.Date now) |
boolean |
hasCacheControlDirective(HttpCacheEntry entry,
java.lang.String directive) |
protected boolean |
hasContentLengthHeader(HttpCacheEntry entry) |
boolean |
isResponseFresh(HttpCacheEntry entry,
java.util.Date now) |
boolean |
isResponseHeuristicallyFresh(HttpCacheEntry entry,
java.util.Date now,
float coefficient,
long defaultLifetime)
Decides if this response is fresh enough based Last-Modified and Date, if available.
|
boolean |
isRevalidatable(HttpCacheEntry entry) |
private boolean |
mayReturnStaleIfError(org.apache.http.Header[] headers,
long stalenessSecs) |
boolean |
mayReturnStaleIfError(org.apache.http.HttpRequest request,
HttpCacheEntry entry,
java.util.Date now) |
boolean |
mayReturnStaleWhileRevalidating(HttpCacheEntry entry,
java.util.Date now) |
boolean |
mustRevalidate(HttpCacheEntry entry) |
boolean |
proxyRevalidate(HttpCacheEntry entry) |
public static final long MAX_AGE
public long getCurrentAgeSecs(HttpCacheEntry entry, java.util.Date now)
public long getFreshnessLifetimeSecs(HttpCacheEntry entry)
public boolean isResponseFresh(HttpCacheEntry entry, java.util.Date now)
public boolean isResponseHeuristicallyFresh(HttpCacheEntry entry, java.util.Date now, float coefficient, long defaultLifetime)
entry
- the cache entrynow
- what time is it currently (When is right NOW)coefficient
- Part of the heuristic for cache entry freshnessdefaultLifetime
- How long can I assume a cache entry is default TTLtrue
if the response is freshpublic long getHeuristicFreshnessLifetimeSecs(HttpCacheEntry entry, float coefficient, long defaultLifetime)
public boolean isRevalidatable(HttpCacheEntry entry)
public boolean mustRevalidate(HttpCacheEntry entry)
public boolean proxyRevalidate(HttpCacheEntry entry)
public boolean mayReturnStaleWhileRevalidating(HttpCacheEntry entry, java.util.Date now)
public boolean mayReturnStaleIfError(org.apache.http.HttpRequest request, HttpCacheEntry entry, java.util.Date now)
private boolean mayReturnStaleIfError(org.apache.http.Header[] headers, long stalenessSecs)
@Deprecated protected java.util.Date getDateValue(HttpCacheEntry entry)
HttpCacheEntry.getDate()
.entry
- protected java.util.Date getLastModifiedValue(HttpCacheEntry entry)
protected long getContentLengthValue(HttpCacheEntry entry)
protected boolean hasContentLengthHeader(HttpCacheEntry entry)
protected boolean contentLengthHeaderMatchesActualLength(HttpCacheEntry entry)
entry
- The cache entry we are currently working withprotected long getApparentAgeSecs(HttpCacheEntry entry)
protected long getAgeValue(HttpCacheEntry entry)
protected long getCorrectedReceivedAgeSecs(HttpCacheEntry entry)
protected long getResponseDelaySecs(HttpCacheEntry entry)
protected long getCorrectedInitialAgeSecs(HttpCacheEntry entry)
protected long getResidentTimeSecs(HttpCacheEntry entry, java.util.Date now)
protected long getMaxAge(HttpCacheEntry entry)
protected java.util.Date getExpirationDate(HttpCacheEntry entry)
public boolean hasCacheControlDirective(HttpCacheEntry entry, java.lang.String directive)
public long getStalenessSecs(HttpCacheEntry entry, java.util.Date now)