Search code examples
androidcachingandroid-volleydiskpicasso

Whether picasso supports image disk caching


Before I had worked on Volley and I have used the DiskLruCache [link] with Volley to cache images on disk.

Now I have been working with app that is using Picasso.

I would like to know whether Picasso supports disk caching. If it supports how can I fix the cache size.

Which will be useful when loading images from remote with disk caching?


Solution

  • Picasso supports disk caching, and it's relying on the HTTP client for this.

    If you're using it with OkHttp, the default size for the disk cache will be around 50 MB (2% of total space, max 50MB, min 5MB).

    If this doesn't meet your needs, you can either implement your own disk cache or manually initialise the OkHttpDownloader with a larger disk cache size when you initialise your Picasso using the Picasso.Builder.

    I would recommend the latter, it should look something like

    new Picasso.Builder(context).downloader(new OkHttpDownloader(MAX_CACHE_SIZE)).build();