public interface HttpCache
| Modifier and Type | Field and Description |
|---|---|
static java.lang.String |
CACHE_DO_NOT_STORE
Do not store the http response
|
static java.lang.String |
CACHE_EXPIRE_AFTER_READ_HEADER
Expire cached response flag http header
|
static java.lang.String |
CACHE_EXPIRE_TIMEOUT_HEADER
Cached response expiration timeout http header
|
static java.lang.String |
CACHE_FETCH_STRATEGY_HEADER
Cache fetch strategy http header
|
static java.lang.String |
CACHE_KEY_HEADER
Cache key http header
|
static java.lang.String |
CACHE_PREFETCH_HEADER
Prefetch response only flag http header
|
static java.lang.String |
CACHE_SERVED_DATE_HEADER
Request served Date/time http header
|
| Modifier and Type | Method and Description |
|---|---|
void |
clear()
Clear cached http responses
|
okhttp3.Interceptor |
interceptor()
Provide http cache interceptor to be injected into
OkHttpClient.interceptors. |
okhttp3.Response |
read(java.lang.String cacheKey)
Read cached http response by key
|
okhttp3.Response |
read(java.lang.String cacheKey,
boolean expireAfterRead)
Read and remove cached http response by key if
expireAfterRead == true |
void |
remove(java.lang.String cacheKey)
Remove cached http response by key.
|
void |
removeQuietly(java.lang.String cacheKey)
Remove cached http response by key and suppress any exception
|
static final java.lang.String CACHE_KEY_HEADER
static final java.lang.String CACHE_FETCH_STRATEGY_HEADER
static final java.lang.String CACHE_SERVED_DATE_HEADER
static final java.lang.String CACHE_PREFETCH_HEADER
static final java.lang.String CACHE_EXPIRE_TIMEOUT_HEADER
static final java.lang.String CACHE_EXPIRE_AFTER_READ_HEADER
static final java.lang.String CACHE_DO_NOT_STORE
void clear()
void remove(@NotNull
java.lang.String cacheKey)
throws java.io.IOException
IOExceptioncacheKey - key of cached response to be removedjava.io.IOExceptionvoid removeQuietly(@NotNull
java.lang.String cacheKey)
cacheKey - key of cached response to be removedokhttp3.Response read(@NotNull
java.lang.String cacheKey)
cacheKey - key of cached response to be readokhttp3.Response read(@NotNull
java.lang.String cacheKey,
boolean expireAfterRead)
expireAfterRead == truecacheKey - key of cached response to be readexpireAfterRead - if true cached response will be removed after first readokhttp3.Interceptor interceptor()
OkHttpClient.interceptors. Provided interceptor
must intercept request and serve cached http response as well as store network response to the http cache store.Interceptor