Anyone got Ktor Client (2.0.0-beta1) to force a re...
# ktor
h
Anyone got Ktor Client (2.0.0-beta1) to force a result from http cache using an
only-if-cached
cache control header? Ktor always responds with status code 504 even if there is a non-stale result in cache.
a
Could you please share a code snippet to illustrate your issue?
h
Configure the client engine with:
Copy code
install(HttpCache)
Send some request:
Copy code
httpClient.get("SOME_URL") {
    header(HttpHeaders.CacheControl, "only-if-cached")
}
Shouldn’t fail with status code 504 if there is a response in the http cache, but it does.
a
Could you please describe what should be returned from a server for
SOME_URL
endpoint or give a link to public resource?
h
In our case, it’s a private REST API that delivers JSON. The response contains correct ETag and Cache-Control headers to work properly with the HttpCache.
a
Is it about Ktor client for the browser JS target?
h
No Android / iOS