Reputation: 601
I am developing an android app.In that app, the server stores the images that is to be displayed in imageView of listview. I use picasso to get image from the server and display in imageview. Though I had uploaded new images in server, only old images are being displayed again. I suspect this is due to cache in picasso. I used 3 methods to prevent cache:
Picasso.with(getActivity()).load(data.get(pos).getFeed_thumb_image()).skipMemoryCache().into(image);
Picasso.with(getActivity()).load(data.get(pos).getFeed_thumb_image()).memoryPolicy(MemoryPolicy.NO_CACHE).into(image);
Picasso.with(context).invalidate(imagePath);
But in no result. How can I clear cache in picasso for particular url?
Upvotes: 1
Views: 1935
Reputation: 131
Try load url with variable like time now: Calendar urlvar = Calendar.getInstance(); int seconds = urlvar.get(Calendar.SECOND);
Then load your url by adding to string: ?urlvar so the final loaded url will be for example example.com/m.png?date it will be cashed but next load the date is changed so the url will change so will not load from cash. Hope ot work
Upvotes: 0
Reputation: 126445
This is going to be implemented in the future, but see the post of Jake Wharton:
JakeWharton commented on 11 Dec 2014 Current best candidate:
picasso.load('http://example.com/')
.cachePolicy(NO_CACHE, NO_STORE)
.networkPolicy(NO_CACHE, NO_STORE, OFFLINE)
.into(imageView);
enum MemoryPolicy {
NO_CACHE, NO_STORE
}
enum NetworkPolicy {
NO_CACHE, NO_STORE, OFFLINE
}
This will be what's implemented unless anyone has other thoughts.
Upvotes: 1