public static class CacheStrategy.Factory
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
private int |
ageSeconds
Age of the cached response.
|
(package private) Response |
cacheResponse |
private java.lang.String |
etag
Etag of the cached response.
|
private java.util.Date |
expires
The expiration date of the cached response, if known.
|
private java.util.Date |
lastModified
The last modified date of the cached response, if known.
|
private java.lang.String |
lastModifiedString |
(package private) long |
nowMillis |
private long |
receivedResponseMillis
Extension header set by OkHttp specifying the timestamp when the cached HTTP response was
first received.
|
(package private) Request |
request |
private long |
sentRequestMillis
Extension header set by OkHttp specifying the timestamp when the cached HTTP request was
first initiated.
|
private java.util.Date |
servedDate
The server's time when the cached response was served, if known.
|
private java.lang.String |
servedDateString |
Constructor and Description |
---|
Factory(long nowMillis,
Request request,
Response cacheResponse) |
Modifier and Type | Method and Description |
---|---|
private long |
cacheResponseAge()
Returns the current age of the response, in milliseconds.
|
private long |
computeFreshnessLifetime()
Returns the number of milliseconds that the response was fresh for, starting from the served
date.
|
CacheStrategy |
get()
Returns a strategy to satisfy
request using the a cached response response . |
private CacheStrategy |
getCandidate()
Returns a strategy to use assuming the request can use the network.
|
private static boolean |
hasConditions(Request request)
Returns true if the request contains conditions that save the server from sending a response
that the client has locally.
|
private boolean |
isFreshnessLifetimeHeuristic()
Returns true if computeFreshnessLifetime used a heuristic.
|
final long nowMillis
final Request request
final Response cacheResponse
private java.util.Date servedDate
private java.lang.String servedDateString
private java.util.Date lastModified
private java.lang.String lastModifiedString
private java.util.Date expires
private long sentRequestMillis
private long receivedResponseMillis
private java.lang.String etag
private int ageSeconds
public CacheStrategy get()
request
using the a cached response response
.private CacheStrategy getCandidate()
private long computeFreshnessLifetime()
private long cacheResponseAge()
private boolean isFreshnessLifetimeHeuristic()
private static boolean hasConditions(Request request)