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:
| Property | Description | Allowed Input | Default |
|---|---|---|---|
enabled | Whether the Cache-Control header should be returned | Boolean | false |
max-age | Set the max-age descriptor | Integer > 0 | |
s-maxage | Set the max-age descriptor | Integer > 0 | |
visibility | Set the visibility of the cached asset | public, private | |
revalidate | Cache control revalidation | must-revalidate, proxy-revalidate, no-cache | |
stale-while-revalidate | Set the stale-while-revalidate descriptor | Integer > 0 | |
stale-if-error | Set the stale-if-error descriptor | Integer > 0 | |
immutable | Whether to set the immutable descriptor | Boolean | false |
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.
{
paths = {
"/users" {
cache-control {
enabled = true
max-age = 1000000
s-maxage = 2000000
immutable = true
}
}
}
}
ETags
ETags and conditional requests are enabled for content and download, regardless of cache-control configuration.
Each ETag identifies the selected representation and changes when its variant or asset metadata changes. Raw pixels
use weak validators (W/); image formats use strong validators.
A matching If-None-Match returns 304 Not Modified without a response body. When both If-None-Match and
If-Modified-Since are supplied, If-None-Match takes precedence. See the
MDN ETag header documentation for more information.