Android Picasso cache with server image

為{幸葍}努か 提交于 2019-12-12 02:51:57

问题


I have a URL link to get images, and that image may change everyday however the link doesn't change.

My questions are

In this case, how Picasso know the image has changed and grab a new image?

Does Picasso fires a url call to my server every-time the image is being used and then determine if the image is different or not?


回答1:


Picasso uses HTTP headers for caching, so it basically follows the HTTP Caching specification. If your server provides accurate headers, it will all be managed automatically. For a nicer explanation you can check this google guide on caching


Edit

Direct answer:

Yes, it will make a request.

But...

You can configure Picasso with a custom downloader using OkHttp and manually decide not to make a request if you have the image already on cache. This is particularly useful when dealing with connection issues (i.e: no internet connection).

Here is an answer about how to make a custom downloader

And some documentation about OkHttp interceptors



来源:https://stackoverflow.com/questions/35236473/android-picasso-cache-with-server-image

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!