Structure
HTTPHeaders.CacheControl
Represents the HTTP
Cache-Control header.struct CacheControl
Overview
See Also: Cache-Control docs
Topics
Structures
HTTPHeaders.CacheControl.MaxStaleThe max-stale option can be present with no value, or be present with a number of seconds. By using a struct you can check the nullability of themaxStalevariable as well as then check the nullability of thesecondsto differentiate.
Initializers
init(mustRevalidated:noCache:noStore:noTransform:isPublic:isPrivate:proxyRevalidate:onlyIfCached:immutable:maxAge:sMaxAge:maxStale:minFresh:staleWhileRevalidate:staleIfError:)Creates a newCacheControl.
Instance Properties
immutableIndicates that the response body will not change over time.isPrivateThe response is for a single user and must not be stored by a shared cache. A private cache (like the user’s browser cache) may store the response.isPublicThe response may be cached by any cache, even if the response is normally non-cacheablemaxAgeThe maximum amount of time a resource is considered fresh. Unlike theExpiresheader, this directive is relative to the time of the request.maxStaleIndicates the client will accept a stale response. An optional value in seconds indicates the upper limit of staleness the client will accept.minFreshIndicates the client wants a response that will still be fresh for at least the specified number of seconds.mustRevalidateIndicates that once a resource becomes stale, caches must not use their stale copy without successful validation on the origin server.noCacheCaches must check with the origin server for validation before using the cached copy.noStoreThe cache should not store anything about the client request or server response.noTransformNo transformations or conversions should be made to the resource. The Content-Encoding, Content-Range, Content-Type headers must not be modified by a proxy. A non-transparent proxy or browser feature such as Google’s Light Mode might, for example, convert between image formats in order to save cache space or to reduce the amount of traffic on a slow link. Theno-transformdirective disallows this.onlyIfCachedIndicates to not retrieve new data. This being the case, the server wishes the client to obtain a response only once and then cache. From this moment the client should keep releasing a cached copy and avoid contacting the origin-server to see if a newer copy exists.proxyRevalidateLikemust-revalidate, but only for shared caches (e.g., proxies). Ignored by private caches.sMaxAgeOverrides max-age or the Expires header, but only for shared caches (e.g., proxies). Ignored by private caches.staleIfErrorIndicates the client will accept a stale response if the check for a fresh one fails. The value indicates how many seconds long the client will accept the stale response after the initial expiration.staleWhileRevalidateIndicates the client will accept a stale response, while asynchronously checking in the background for a fresh one. The value indicates how long the client will accept a stale response.
Instance Methods
serialize()Generates the header string for this instance.
Type Methods
Relationships
Conforms To
Swift.SendableSwift.SendableMetatype