2

I am using Picasso to download images, and have custom OKHttp download client implementation in which we have created a custom cache of around 153MB. I'm wondering if this will override the default memory cache that Picasso has 15% of the allotted RAM on the device.

BlackHatSamurai
  • 23,275
  • 22
  • 95
  • 156

1 Answers1

1

Setting the HTTP client's disk cache does not affect Picasso's memory cache.

The disk cache inside OkHttp caches the raw responses received from making HTTP requests. It does this according to the HTTP caching headers which come back on the responses and stores them in an LRU on the file system. Since the responses are stored as opaque bytes, these are the full-size images which are being downloaded.

Picasso has a memory cache which stores the decoded and transformed images. These are the result of asking the HTTP client for a request and decoding the bytes it returns (either from the disk cache or from the network) into a Bitmap object. These objects are also stored in a LRU but in memory.

These two caching layers do not interact with each other at all. So defining a custom HTTP cache will not affect the memory cache in any way, just as altering the memory cache configuration won't affect how the HTTP cache works.

Jake Wharton
  • 75,598
  • 23
  • 223
  • 230