Class CacheValidityPolicy
- java.lang.Object
-
- org.apache.http.impl.client.cache.CacheValidityPolicy
-
@Contract(threading=IMMUTABLE) class CacheValidityPolicy extends java.lang.Object
- Since:
- 4.1
-
-
Field Summary
Fields Modifier and Type Field Description static long
MAX_AGE
-
Constructor Summary
Constructors Constructor Description CacheValidityPolicy()
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method 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) useHttpCacheEntry.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)
-
-
-
Field Detail
-
MAX_AGE
public static final long MAX_AGE
- See Also:
- Constant Field Values
-
-
Method Detail
-
getCurrentAgeSecs
public long getCurrentAgeSecs(HttpCacheEntry entry, java.util.Date now)
-
getFreshnessLifetimeSecs
public long getFreshnessLifetimeSecs(HttpCacheEntry entry)
-
isResponseFresh
public boolean isResponseFresh(HttpCacheEntry entry, java.util.Date now)
-
isResponseHeuristicallyFresh
public 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. This entry is meant to be used when isResponseFresh returns false. The algorithm is as follows: if last-modified and date are defined, freshness lifetime is coefficient*(date-lastModified), else freshness lifetime is defaultLifetime- Parameters:
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 TTL- Returns:
true
if the response is fresh
-
getHeuristicFreshnessLifetimeSecs
public long getHeuristicFreshnessLifetimeSecs(HttpCacheEntry entry, float coefficient, long defaultLifetime)
-
isRevalidatable
public boolean isRevalidatable(HttpCacheEntry entry)
-
mustRevalidate
public boolean mustRevalidate(HttpCacheEntry entry)
-
proxyRevalidate
public boolean proxyRevalidate(HttpCacheEntry entry)
-
mayReturnStaleWhileRevalidating
public boolean mayReturnStaleWhileRevalidating(HttpCacheEntry entry, java.util.Date now)
-
mayReturnStaleIfError
public boolean mayReturnStaleIfError(org.apache.http.HttpRequest request, HttpCacheEntry entry, java.util.Date now)
-
mayReturnStaleIfError
private boolean mayReturnStaleIfError(org.apache.http.Header[] headers, long stalenessSecs)
-
getDateValue
@Deprecated protected java.util.Date getDateValue(HttpCacheEntry entry)
Deprecated.(4.3) useHttpCacheEntry.getDate()
.- Parameters:
entry
-- Returns:
-
getLastModifiedValue
protected java.util.Date getLastModifiedValue(HttpCacheEntry entry)
-
getContentLengthValue
protected long getContentLengthValue(HttpCacheEntry entry)
-
hasContentLengthHeader
protected boolean hasContentLengthHeader(HttpCacheEntry entry)
-
contentLengthHeaderMatchesActualLength
protected boolean contentLengthHeaderMatchesActualLength(HttpCacheEntry entry)
This matters for deciding whether the cache entry is valid to serve as a response. If these values do not match, we might have a partial response- Parameters:
entry
- The cache entry we are currently working with- Returns:
- boolean indicating whether actual length matches Content-Length
-
getApparentAgeSecs
protected long getApparentAgeSecs(HttpCacheEntry entry)
-
getAgeValue
protected long getAgeValue(HttpCacheEntry entry)
-
getCorrectedReceivedAgeSecs
protected long getCorrectedReceivedAgeSecs(HttpCacheEntry entry)
-
getResponseDelaySecs
protected long getResponseDelaySecs(HttpCacheEntry entry)
-
getCorrectedInitialAgeSecs
protected long getCorrectedInitialAgeSecs(HttpCacheEntry entry)
-
getResidentTimeSecs
protected long getResidentTimeSecs(HttpCacheEntry entry, java.util.Date now)
-
getMaxAge
protected long getMaxAge(HttpCacheEntry entry)
-
getExpirationDate
protected java.util.Date getExpirationDate(HttpCacheEntry entry)
-
hasCacheControlDirective
public boolean hasCacheControlDirective(HttpCacheEntry entry, java.lang.String directive)
-
getStalenessSecs
public long getStalenessSecs(HttpCacheEntry entry, java.util.Date now)
-
-