struct

Marten::CDNCache::Policy

Inherits Struct < Value < Object

An immutable description of how a response should be cached.

visibility is :public (CDN-cacheable) or :private. A private policy with no max_age renders as private, no-store — the conservative default. strip_cookies is only ever honored by the middleware on public responses.

Constants

VALID_VISIBILITIES = {:public, :private}

Constructors

deserialize(value : String) : Policy
immutable_asset(max_age : Int32 = 31536000) : Policy

A long-lived immutable asset policy (content-fingerprinted files).

new(visibility : Symbol = :private, max_age : Int32 | Nil = nil, s_maxage : Int32 | Nil = nil, immutable : Bool = false, strip_cookies : Bool = false)
private_no_store

The conservative default: not cacheable anywhere.

public_cached(max_age : Int32, s_maxage : Int32 | Nil = nil, immutable : Bool = false, strip_cookies : Bool = true) : Policy

A public, CDN-cacheable page policy. Strips cookies by default since the response is going to a shared cache.

Instance methods

cache_control_header

Renders the Cache-Control header value for this policy.

immutable
max_age
public?
s_maxage
serialize

Compact serialization used to carry a handler-selected policy through an internal response header (see Cacheable/Uncacheable). Never sent to the client — the middleware deletes the header after reading it.

strip_cookies
visibility