'Coil image caching

I load my images into an android app with the Coil library. And it instantly shows me cached images if there is no internet. But when there is an internet connection, the Coil loads images again, and for a while I see the placeholder. I think it's a very strange logic. How can I make it show me the cached images instantly even if there is an internet connection?

My current code:

fun ImageView.setPhoto(photoLink: String) {
    load(photoLink) {
        crossfade(true)
        placeholder(R.drawable.placeholder)
        error(R.drawable.placeholder)
        size(ViewSizeResolver(this@setPhoto))
    }
}


Solution 1:[1]

Try disabling the cache headers support.

val imageLoader = ImageLoader.Builder(context)
        .respectCacheHeaders(false)
        .build()
Coil.setImageLoader(imageLoader)

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Serhii Petrenko