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 longMAX_AGE
-
Constructor Summary
Constructors Constructor Description CacheValidityPolicy()
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description protected booleancontentLengthHeaderMatchesActualLength(HttpCacheEntry entry)This matters for deciding whether the cache entry is valid to serve as a response.protected longgetAgeValue(HttpCacheEntry entry)protected longgetApparentAgeSecs(HttpCacheEntry entry)protected longgetContentLengthValue(HttpCacheEntry entry)protected longgetCorrectedInitialAgeSecs(HttpCacheEntry entry)protected longgetCorrectedReceivedAgeSecs(HttpCacheEntry entry)longgetCurrentAgeSecs(HttpCacheEntry entry, java.util.Date now)protected java.util.DategetDateValue(HttpCacheEntry entry)Deprecated.(4.3) useHttpCacheEntry.getDate().protected java.util.DategetExpirationDate(HttpCacheEntry entry)longgetFreshnessLifetimeSecs(HttpCacheEntry entry)longgetHeuristicFreshnessLifetimeSecs(HttpCacheEntry entry, float coefficient, long defaultLifetime)protected java.util.DategetLastModifiedValue(HttpCacheEntry entry)protected longgetMaxAge(HttpCacheEntry entry)protected longgetResidentTimeSecs(HttpCacheEntry entry, java.util.Date now)protected longgetResponseDelaySecs(HttpCacheEntry entry)longgetStalenessSecs(HttpCacheEntry entry, java.util.Date now)booleanhasCacheControlDirective(HttpCacheEntry entry, java.lang.String directive)protected booleanhasContentLengthHeader(HttpCacheEntry entry)booleanisResponseFresh(HttpCacheEntry entry, java.util.Date now)booleanisResponseHeuristicallyFresh(HttpCacheEntry entry, java.util.Date now, float coefficient, long defaultLifetime)Decides if this response is fresh enough based Last-Modified and Date, if available.booleanisRevalidatable(HttpCacheEntry entry)private booleanmayReturnStaleIfError(org.apache.http.Header[] headers, long stalenessSecs)booleanmayReturnStaleIfError(org.apache.http.HttpRequest request, HttpCacheEntry entry, java.util.Date now)booleanmayReturnStaleWhileRevalidating(HttpCacheEntry entry, java.util.Date now)booleanmustRevalidate(HttpCacheEntry entry)booleanproxyRevalidate(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:
trueif 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)
-
-