Question

I'm using picasso to download some images from amazon s3 and applying transform in different areas of the android app. Using debbuging i notice that, for every call with a different transform or imageview size, picasso will download it again and cache the transformed image in memory. Is there a correct way to make picasso store the original image in cache and later apply transformations without having to download it all over again? Network Bandwidth is an issue for my user case.

Was it helpful?

Solution

Original images will be stored in the disk cache. Ensure that your server is sending down correct headers to allow caching for whatever period of time you desire. When the second request is made and the image is already in the disk cache, it will be returned immediately.

By default, disk caching only works on Android 4.0 and newer because that's when it was introduced into the built-in HTTP client. For caching on all API levels, include [OkHttp][1] in your app. Picasso will see OkHttp automatically and use it. This will not only provide you with caching everywhere but also with an all-around better HTTP client.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top