Hristijan
09/10/2024, 6:43 PMException in thread "main" io.ktor.server.application.DuplicatePluginException: Please make sure that you use unique name for the plugin and don't install it twice. Plugin `Caching Headers` is already installed to the pipeline
since there’s no docs for 3.0.0-rc-1, here’s the link to the beta2 https://ktor.io/docs/3.0.0-beta-2/server-caching-headers.html#configure-route which worked fineHristijan
09/10/2024, 6:46 PMfun Application.caching() {
install(CachingHeaders)
}
fun Routing.cachedRoute(
maxAgeSeconds: Int
) {
install(CachingHeaders) {
options { _, _ -> CachingOptions(CacheControl.MaxAge(maxAgeSeconds = maxAgeSeconds)) }
}
}
i have these simple helper functions, pretty self explanatoryHristijan
09/10/2024, 6:47 PMRouting.cachedRoute
from my routes, it’s okay, it worksAleksei Tirman [JB]
09/10/2024, 7:00 PMException in thread "main" io.ktor.server.application.DuplicatePluginException: Installing RouteScopedPlugin to application and route is not supported. Consider moving application level install to routing root.
Aleksei Tirman [JB]
09/10/2024, 7:00 PMfun main() {
embeddedServer(Netty, port = 8081, host = "127.0.0.1") {
caching()
routing {
cachedRoute(100)
}
}.start(wait = true)
}