Hi, I’m currently upgrading my project to ktor2. I...
# ktor
d
Hi, I’m currently upgrading my project to ktor2. I use [
CachingHeader
plugin](https://ktor.io/docs/caching.html), and
CachingOptions
(io.ktor.server.http.content) class shows compile errors because it became to need
expires
parameter (non nullable). As I know, If we want to return
Cache-Control: no-cache
as http response, then
expires
header is not required. Why is this parameter required?
a
As I can see, the
expires
parameter is nullable with a default
null
value in Ktor 2.0.2:
Copy code
public data class CachingOptions(val cacheControl: CacheControl? = null, val expires: GMTDate? = null)
So I can write a code like this:
Copy code
install(CachingHeaders) {
    options { call, outgoingContent ->
        CachingOptions(CacheControl.NoCache(CacheControl.Visibility.Public))
    }
}
d
Oh, I used io.ktor.server.http.content.CachingOptions, but I replaces it with io.ktor.http.content.CachingOptions so it works well. You made me aware of it. Thank you.