Skip to main content

HTTP Caching

Konifer exposes highly-customizable Cache-Control headers. Due to the relative nature of the API, no assumptions are made regarding the appropriate Cache-Control header to apply to an asset.

Cache-Control Configuration

The Cache-Control header can be configured per-path. The following options are available:

PropertyDescriptionAllowed InputDefault
enabledWhether the Cache-Control header should be returnedBooleanfalse
max-ageSet the max-age descriptorInteger > 0
s-maxageSet the max-age descriptorInteger > 0
visibilitySet the visbility of the cached assetpublic, private
revalidateCache control revalidationmust-revalidate, proxy-revalidate, no-cache
stale-while-revalidate Set the stale-while-revalidate descriptorInteger > 0
stale-if-error Set the stale-if-error descriptorInteger > 0
immutableWhether to set the immutable descriptorBooleanfalse
caution

Konifer does not validate proper semantic Cache-Control configurations.

Usage

To configure, specify properties within the cache-control block of your path configuration. You can explore more about the proper usage of Cache-Control header directives here.

{
paths = [
{
path = "/users"
cache-control {
enabled = true
max-age = 1000000
s-maxage = 2000000
immutable = true
}
}
]
}

Etags

Etags are always enabled and are returned regardless of your cache-control configuration. Etags and conditional validation are only enabled when returning asset in the content return format. The usage of Etags is outside of the scope of this document and can be explored further here.