okhttp / okhttp3 / CacheControl / Builder

Builder

class Builder

Builds a Cache-Control request header.

Constructors

<init>

Builder()

Builds a Cache-Control request header.

Functions

build

fun build(): CacheControl

immutable

fun immutable(): CacheControl.Builder

maxAge

fun maxAge(maxAge: Int, timeUnit: TimeUnit): CacheControl.Builder

Sets the maximum age of a cached response. If the cache response's age exceeds maxAge, it will not be used and a network request will be made.

maxStale

fun maxStale(maxStale: Int, timeUnit: TimeUnit): CacheControl.Builder

Accept cached responses that have exceeded their freshness lifetime by up to maxStale. If unspecified, stale cache responses will not be used.

minFresh

fun minFresh(minFresh: Int, timeUnit: TimeUnit): CacheControl.Builder

Sets the minimum number of seconds that a response will continue to be fresh for. If the response will be stale when minFresh have elapsed, the cached response will not be used and a network request will be made.

noCache

fun noCache(): CacheControl.Builder

Don't accept an unvalidated cached response.

noStore

fun noStore(): CacheControl.Builder

Don't store the server's response in any cache.

noTransform

fun noTransform(): CacheControl.Builder

Don't accept a transformed response.

onlyIfCached

fun onlyIfCached(): CacheControl.Builder

Only accept the response if it is in the cache. If the response isn't cached, a 504 Unsatisfiable Request response will be returned.