Controlling cache headers
This feature is defined in the class io.ktor.features.CachingHeaders
and no additional artifacts are required.
The options configuration method, allows you to define code to optionally select a CachingOptions
from a provided outgoingContent: OutgoingContent
.You can, for example, use the of the outgoing message to determine which Cache-Control to use.
data class CachingOptions(val cacheControl: CacheControl? = null, val expires: ZonedDateTime? = null)
enum class Visibility { Public, Private }
class NoCache(visibility: Visibility?) : CacheControl(visibility)
class NoStore(visibility: Visibility?) : CacheControl(visibility)
If you have several options, that would append several Cache-Control
headers per each matching option.