Skip to content

//okhttp/okhttp3/CacheControl

CacheControl

[common]\ expect class CacheControl

A Cache-Control header with cache directives from a server or client. These directives set policy on what responses can be stored, and which requests can be satisfied by those stored responses.

See RFC 7234, 5.2.

[jvm, nonJvm]\ actual class CacheControl

Types

Name Summary
Builder [common]
expect class Builder
Builds a Cache-Control request header.
[jvm, nonJvm]
[jvm, nonJvm]
actual class Builder
Companion [common, jvm, nonJvm]
[common]
expect object Companion
[jvm, nonJvm]
actual object Companion

Functions

Name Summary
toString [common, jvm, nonJvm]
[common]
expect open override fun toString(): String
[jvm, nonJvm]
actual open override fun toString(): String

Properties

Name Summary
immutable [common]
expect val immutable: Boolean
[jvm]
@get:JvmName(name = "immutable")
actual val immutable: Boolean
[nonJvm]
actual val immutable: Boolean
isPrivate [common]
expect val isPrivate: Boolean
[jvm, nonJvm]
actual val isPrivate: Boolean
isPublic [common]
expect val isPublic: Boolean
[jvm, nonJvm]
actual val isPublic: Boolean
maxAgeSeconds [common]
expect val maxAgeSeconds: Int
The duration past the response’s served date that it can be served without validation.
[jvm]
@get:JvmName(name = "maxAgeSeconds")
actual val maxAgeSeconds: Int
[nonJvm]
actual val maxAgeSeconds: Int
maxStaleSeconds [common]
expect val maxStaleSeconds: Int
[jvm]
@get:JvmName(name = "maxStaleSeconds")
actual val maxStaleSeconds: Int
[nonJvm]
actual val maxStaleSeconds: Int
minFreshSeconds [common]
expect val minFreshSeconds: Int
[jvm]
@get:JvmName(name = "minFreshSeconds")
actual val minFreshSeconds: Int
[nonJvm]
actual val minFreshSeconds: Int
mustRevalidate [common]
expect val mustRevalidate: Boolean
[jvm]
@get:JvmName(name = "mustRevalidate")
actual val mustRevalidate: Boolean
[nonJvm]
actual val mustRevalidate: Boolean
noCache [common]
expect val noCache: Boolean
In a response, this field’s name "no-cache" is misleading. It doesn’t prevent us from caching the response; it only means we have to validate the response with the origin server before returning it. We can do this with a conditional GET.
[jvm]
@get:JvmName(name = "noCache")
actual val noCache: Boolean
[nonJvm]
actual val noCache: Boolean
noStore [common]
expect val noStore: Boolean
If true, this response should not be cached.
[jvm]
@get:JvmName(name = "noStore")
actual val noStore: Boolean
[nonJvm]
actual val noStore: Boolean
noTransform [common]
expect val noTransform: Boolean
[jvm]
@get:JvmName(name = "noTransform")
actual val noTransform: Boolean
[nonJvm]
actual val noTransform: Boolean
onlyIfCached [common]
expect val onlyIfCached: Boolean
This field’s name "only-if-cached" is misleading. It actually means "do not use the network". It is set by a client who only wants to make a request if it can be fully satisfied by the cache. Cached responses that would require validation (ie. conditional gets) are not permitted if this header is set.
[jvm]
@get:JvmName(name = "onlyIfCached")
actual val onlyIfCached: Boolean
[nonJvm]
actual val onlyIfCached: Boolean
sMaxAgeSeconds [common]
expect val sMaxAgeSeconds: Int
The "s-maxage" directive is the max age for shared caches. Not to be confused with "max-age" for non-shared caches, As in Firefox and Chrome, this directive is not honored by this cache.
[jvm]
@get:JvmName(name = "sMaxAgeSeconds")
actual val sMaxAgeSeconds: Int
[nonJvm]
actual val sMaxAgeSeconds: Int