https://kotlinlang.org logo
#ktor
Title
# ktor
l

Luis Munoz

06/30/2020, 3:33 AM
is it possible to disable caching of static content? I want it to read my html file from disk each time, is this possible?
Copy code
spring:
  resources:
    static-locations[0]: file:src/main/resources/static/
    static-locations[1]: classpath:/static/
    cache:
      period: 0
      cachecontrol:
        s-max-age: 0
        no-store: true
In spring boot it would the above config
Copy code
static("/") {
    val root = File("rest-api/webapp")
    if(!root.exists()) {
        throw RuntimeException("Unable to locate static content")
    }
    staticRootFolder = root
    default("index.html")
}
what I have right now
best I came up with
Copy code
fun Route.defaultWithNoCache(localPath: File) {
    get {
        if (localPath.isFile) {
            call.response.cacheControl(CacheControl.NoCache(CacheControl.Visibility.Private))
            call.respond(LocalFileContent(localPath))
        }
    }
}
seems ugly because I can't use
Copy code
staticRootFolder
doing that
47 Views