picasso loading old images from cache after images being updated on server

Created on 1 Nov 2015  Â·  11Comments  Â·  Source: square/picasso

hey , I'm new to picasso . Its amazing library with great capabilities . Im using it to load images from url . in my code i might update the image on the server keeping the same URL . my problem is that after updating the image picasso is still displaying the old image from cache and not from URL . I already know why because the URL is the same . so please i need help in case there is a way to let picasso know that image should be loaded again from server instead cache . Ive tried to invalidate URL after updating certain image but when i went offline images failed to load from cache although they were loaded again !

Most helpful comment

After using .memoryPolicy, the image was still not changing. After using .networkPolicy(NetworkPolicy.NO_CACHE)
It worked perfectly. Thank you!

All 11 comments

This might be because of the Expires or Cache Policy headers.

Can you please provide your headers?

You can use .memoryPolicy(MemoryPolicy.NO_CACHE) on the next request which will skip Picasso's cache. There's also .networkPolicy(NetworkPolicy.NO_CACHE) if you need to bust the HTTP cache.

Excellent answer .memoryPolicy(MemoryPolicy.NO_CACHE)
Thanks alot

After using .memoryPolicy, the image was still not changing. After using .networkPolicy(NetworkPolicy.NO_CACHE)
It worked perfectly. Thank you!

Hi, how about the use case when image is changed for example once a year. I don't wanna set policy to NO_CACHE, because i want caching enabled. URL is still the same after update, how long will it take to load new version?

It will be loaded once per application launch or when evicted from the
cache by loading a bunch of other images.

On Thu, Sep 7, 2017 at 8:37 AM JerabekJakub notifications@github.com
wrote:

Hi, how about the use case when image is changed for example once a year.
I don't wanna set policy to NO_CACHE, because i want caching enabled. URL
is still the same after update, how long will it take to load new version?

—
You are receiving this because you modified the open/close state.
Reply to this email directly, view it on GitHub
https://github.com/square/picasso/issues/1186#issuecomment-327786509,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AAEEEZDLbLCRK9aNuBM2G_U9nERbTCgIks5sf-OngaJpZM4GZwjF
.

Why is this issue closed? I bumped into this problem. Is there a way to force Picasso update it's cached image?

You can use the memory and disk cache APIs on RequestBuilder to control
that.

On Thu, Feb 22, 2018 at 8:45 AM Alexander notifications@github.com wrote:

Why is this issue closed? I bumped into this problem. Is it a way to force
Picasso update it's cached image?

—
You are receiving this because you modified the open/close state.
Reply to this email directly, view it on GitHub
https://github.com/square/picasso/issues/1186#issuecomment-367685141,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AAEEEawalf9w50GZ1LqjL5bRheGti9Niks5tXW-OgaJpZM4GZwjF
.

Thank you, Jake! It's the first time when such a famous person replies me. I looked for "Request.Builder" and understood that it was better to make Picasso as a Singleton in Application class. In my case a user receives an image from gallery or camera and saves it in a temporary file. If then the user gets a new photo it should be moved into a file and shown again. So now I use different file names, but probably it will be better to use the same.

In my case picasso loading image again, seems like it didnt cached image

Try this @CoolMind @blackhawk389

Picasso.get().invalidate("THAT URL")

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ghost picture ghost  Â·  6Comments

sd6352051 picture sd6352051  Â·  7Comments

caoguodong picture caoguodong  Â·  3Comments

JakeWharton picture JakeWharton  Â·  3Comments

ivanmagdic picture ivanmagdic  Â·  3Comments