WriteOptions
12345678910111213141516171819type WriteOptions struct { TTL time.Duration
RequestHeaders fsthttp.Header
Vary []string
InitialAge time.Duration
StaleWhileRevalidate time.Duration
SurrogateKeys []string
Length uint64
UserMetadata []byte
SensitiveData bool}WriteOptions control the behavior of cache inserts and updates. TTL is required, but all other fields are optional.
Fields
TTL is the maximum time the cached object will be considered fresh. Required.
RequestHeaders
fsthttp.HeaderRequestHeaders are a set of HTTP headers that influence cache lookups when Vary rules are set.
This field is only valid for Insert outside of a transaction. If provided to Insert or Update inside a transaction, ErrInvalidArgument will be returned.
Vary is a list of HTTP header names (provided in RequestHeaders) that must match when looking up this key.
InitialAge
time.DurationInitialAge is the initial age of the cached object.
StaleWhileRevalidate
time.DurationStaleWhileRevalidate is the period of time in which the cached object can be served stale while revalidation is taking place.
This provides a signal that the cache should be updated (or its contents otherwise revalidated for freshness) asynchronously, while the stale cached object continues to be used, rather than blocking on updating the cached object. The methods Usable and Stale can be used to determine the current state of a found item.
SurrogateKeys is a list of surrogate keys which can be used to purge this object.
Surrogate key purges are the only means to purge specific items from the cache. At least one surrogate key must be set in order to remove an item without performaing a purge-all, waiting for the item's TTL to elapse, or overwriting the item with Insert.
Surrogate keys must contain only printable ASCII characters (those between 0x21 and 0x7E, inclusive). Any invalid keys will be ignored.
See the Fastly surrogate keys guide for details: https://docs.fastly.com/en/guides/purging-api-cache-with-surrogate-keys
Length sets the size of the cached object, in bytes, when known prior to actually providing the bytes.
It is preferable to provide a length, if possible. Clients that begin streaming the object's contents before it is completely provided will see the promised length which allows them to, for example, use Content-Length instead of chunked Transfer-Encoding if the item is used as the body of an HTTP request or response.
UserMetadata is abitrary user-provided metadata that will be associated with the cached object.
SensitiveData indiciates whether to enable PCI/HIPAA-compliant non-volatile caching.
See the Fastly PCI-Compliant Caching and Delivery documentation for details: https://docs.fastly.com/products/pci-compliant-caching-and-delivery