https://kotlinlang.org logo
Title
n

Nick Williams

02/06/2023, 1:21 PM
question on the inner workings of ktor: if you make a request and then another identical request whilst the first one is still awaiting a response does the second request also await the outcome of the first request or does it generate another network round trip?
d

Dariusz Kuc

02/06/2023, 2:15 PM
I'd imagine that by default those would be treated as two separate requests. I'm guessing you would need some sort of caching mechanism in the pipeline to only make single request.
n

Nick Williams

02/06/2023, 3:00 PM
By caching mechanism do you mean just adding the HttpCache plugin?
d

Dariusz Kuc

02/06/2023, 3:08 PM
unsure what that plugin does, guessing no but check docs
n

Nick Williams

02/06/2023, 3:09 PM
Nothing in docs
d

Dariusz Kuc

02/06/2023, 3:09 PM
so probably not
a

Aleksei Tirman [JB]

02/07/2023, 8:49 PM
If an endpoint allows caching its responses then you can use the
HttpCache
plugin to cache a response from the first request and have it for the second one without making a network call. However, this depends on when the second request is fired.