The Ktor client provides the HttpCache plugin that allows you to save previously fetched resources in an in-memory cache.
HttpCache only requires the ktor-client-core artifact and doesn't need any specific dependencies.
HttpCache, pass it to the
install function inside a client configuration block:
This is enough to enable the client to save previously fetched resources in a cache. For example, if you make two consequent requests to a resource with the configured
Cache-Control header, the client executes only the first request and skips the second one since data is already saved in a cache.
You can find a runnable example here: client-caching.