CacheControl
Represents the HTTP Cache-Control header.
struct CacheControlRepresents the HTTP Cache-Control header.
struct CacheControlimport NIOHTTP1import VaporVapor is a framework for building server applications, APIs and websites in Swift. It provides a safe, performant and scalable foundation for building large complex backends.
struct HTTPHeadersA representation of a block of HTTP header fields.
init(from decoder: any Decoder) throws var accept: [HTTPMediaTypePreference] { get }Returns a collection of MediaTypePreferences specified by this HTTP message’s "Accept" header.
var basicAuthorization: BasicAuthorization? { get set }Access or set the Authorization: Basic: ... header.
var bearerAuthorization: BearerAuthorization? { get set }Access or set the Authorization: Bearer: ... header.
var cacheControl: CacheControl? { get set }Gets the value of the Cache-Control header, if present.
var connection: Connection? { get set }var contentDisposition: ContentDisposition? { get set }Convenience for accessing the Content-Disposition header.
var contentRange: ContentRange? { get set }Convenience for accessing the Content-Range response header.
var contentType: HTTPMediaType? { get set }MediaType specified by this message’s "Content-Type" header.
var cookie: HTTPCookies? { get set }Get and set HTTPCookies for an HTTP request This accesses the "Cookie" header.
var debugDescription: String { get }See CustomDebugStringConvertible.debugDescription
var expires: Expires? { get set }Gets the value of the Expires header, if present.
var forwarded: [Forwarded] { get set }Convenience for accessing the Forwarded header. This header is added by proxies to pass information about the original request.
var lastModified: LastModified? { get set }var links: [Link]? { get set }Convenience for accessing the Link header as an array of provided links.
var range: Range? { get set }Convenience for accessing the Range request header.
var responseCompression: ResponseCompression { get set }A marker header internal to vapor that explicitely allows or disallows response compression.
var setCookie: HTTPCookies? { get set }Get and set HTTPCookies for an HTTP response This accesses the "Set-Cookie" header.
subscript(name: Name) -> [String] { get } Retrieve all of the values for a given header field name from the block.
subscript(canonicalForm name: Name) -> [Substring] { get } mutating func add(name: Name, value: String) Add a header name/value pair to the block.
func contains(name: Name) -> Bool Returns true if the HTTPHeaders contains a value for the supplied name.
func encode(to encoder: any Encoder) throws func expirationDate(requestSentAt: Date) -> Date? Determines when the cached data should be expired.
func first(name: Name) -> String? Returns the first header value with the supplied name.
mutating func remove(name: Name) Remove all values for a given header name from the block.
mutating func replaceOrAdd(name: Name, value: String) Add a header name/value pair to the block, replacing any previous values for the same header name that are already in the block.
struct Connectionstruct ContentDispositionstruct ContentRangeRepresents the HTTP Content-Range response header.
struct Expiresstruct ForwardedParses the Forwarded header.
struct LastModifiedRepresents the HTTP Last-Modified header.
struct Linkstruct NameType used for the name of a HTTP header in the HTTPHeaders storage.
struct RangeRepresents the HTTP Range request header. See https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Range
enum RangeUnitThe unit in which ContentRanges and Ranges are specified. This is usually bytes. See https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Range
struct ResponseCompressionA marker header internal to vapor that explicitely allows or disallows response compression.
protocol Sendableinit(mustRevalidated: Bool = false, noCache: Bool = false, noStore: Bool = false, noTransform: Bool = false, isPublic: Bool = false, isPrivate: Bool = false, proxyRevalidate: Bool = false, onlyIfCached: Bool = false, immutable: Bool = false, maxAge: Int? = nil, sMaxAge: Int? = nil, maxStale: MaxStale? = nil, minFresh: Int? = nil, staleWhileRevalidate: Int? = nil, staleIfError: Int? = nil) Creates a new CacheControl.
static func parse(_ value: String) -> CacheControl? var immutable: BoolIndicates that the response body will not change over time.
var isPrivate: BoolThe 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.
var isPublic: BoolThe response may be cached by any cache, even if the response is normally non-cacheable
var maxAge: Int?The maximum amount of time a resource is considered fresh. Unlike theExpires header, this directive is relative to the time of the request.
var maxStale: MaxStale?Indicates the client will accept a stale response. An optional value in seconds indicates the upper limit of staleness the client will accept.
var minFresh: Int?Indicates the client wants a response that will still be fresh for at least the specified number of seconds.
var mustRevalidate: BoolIndicates that once a resource becomes stale, caches must not use their stale copy without successful validation on the origin server.
var noCache: BoolCaches must check with the origin server for validation before using the cached copy.
var noStore: BoolThe cache should not store anything about the client request or server response.
var noTransform: BoolNo 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. The no-transform directive disallows this.
var onlyIfCached: BoolIndicates 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.
var proxyRevalidate: BoolLike must-revalidate, but only for shared caches (e.g., proxies). Ignored by private caches.
var sMaxAge: Int?Overrides max-age or the Expires header, but only for shared caches (e.g., proxies). Ignored by private caches.
var staleIfError: Int?Indicates 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.
var staleWhileRevalidate: Int?Indicates 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.
func serialize() -> String Generates the header string for this instance.
struct 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 the maxStale variable as well as then check the nullability of the seconds to differentiate.