Picasso: What is default cache policy?

Created on 8 Oct 2015  Â·  7Comments  Â·  Source: square/picasso

May I know what is the default cache policy? (I assume 2.5.2 got its own caching mechanism which doesn't rely on okhttp)

  • How big is the cache size for local file and memory / how to change it?
  • What is the algo to decide which cache got cleared first?
  • Any API/Settings to manipulate the caching mechanism?

Most helpful comment

Thanks. I assume the following is the correct code to increase disk cache size to 250MB

    Picasso picasso =  new Picasso.Builder(this).downloader(new OkHttpDownloader(getCacheDir(), 250000000)).build();
    Picasso.setSingletonInstance(picasso);

All 7 comments

How big is the cache size for local file and memory / how to change it?

Disk cache is 50MB I think. Memory is 1/7th heap size.

You can chance it by calling setCache on the builder for memory cache or by installing your own disk cache on the HTTP client.

What is the algo to decide which cache got cleared first?

Memory is LRU. Disk cache is up to whatever HTTP client you are using, presumably it follows RFC 7234 rules (or the like).

Any API/Settings to manipulate the caching mechanism?

See first answer.

I assume 2.5.2 got its own caching mechanism which doesn't rely on okhttp

No. Nothing changed.

Thanks. I assume the following is the correct code to increase disk cache size to 250MB

    Picasso picasso =  new Picasso.Builder(this).downloader(new OkHttpDownloader(getCacheDir(), 250000000)).build();
    Picasso.setSingletonInstance(picasso);

Yep!

On Thu, Oct 8, 2015 at 10:39 PM luaz [email protected] wrote:

Thanks. I assume the following is the correct code to increase disk cache
size to 250MB

Picasso picasso =  new Picasso.Builder(this).downloader(new OkHttpDownloader(getCacheDir(), 250000000)).build();
Picasso.setSingletonInstance(picasso);

—
Reply to this email directly or view it on GitHub
https://github.com/square/picasso/issues/1154#issuecomment-146739864.

How to change the default disk cache policy? I have tried to use cache-control headers for the image, cache-control: public, max-age=60 but it is not working. Is there a way to set an expiry time for images while storing in the disk?

Picasso doesn't have a disk cache. OkHttp maintains an HTTP cache which is
controlled by HTTP cache headers (which Picasso has no control over).

On Mon, Jan 20, 2020, 6:18 AM PavanBilagi notifications@github.com wrote:

How to change the default disk cache policy? I have tried to use
cache-control headers for the image,
but it is not working. Is there a way to set an expiry time for images
while storing in the disk?

—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/square/picasso/issues/1154?email_source=notifications&email_token=AAAQIELMV2IORI76GEIWEX3Q6WCAHA5CNFSM4BROAHQKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEJMI44Y#issuecomment-576228979,
or unsubscribe
https://github.com/notifications/unsubscribe-auth/AAAQIEOV453ZVXJ5NXKDSS3Q6WCAHANCNFSM4BROAHQA
.

Thanks @JakeWharton will raise it in https://github.com/square/okhttp/issues

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ChrisCraik picture ChrisCraik  Â·  5Comments

nitingrov86 picture nitingrov86  Â·  4Comments

jaycee88 picture jaycee88  Â·  6Comments

JakeWharton picture JakeWharton  Â·  7Comments

ghost picture ghost  Â·  6Comments