How to set image using Kingfisher when image url did not change but image changed

我怕爱的太早我们不能终老 提交于 2019-12-23 11:54:40

问题


How to retrieve correct image using Kingfisher when image url did not change but image changed such as Twitter or GitHub.

SDWebImage has a option [SDWebImageRefreshCached] to solve the problem.

   /**
     * Even if the image is cached, respect the HTTP response cache control, and refresh the image from remote location if needed.
     * The disk caching will be handled by NSURLCache instead of SDWebImage leading to slight performance degradation.
     * This option helps deal with images changing behind the same request URL, e.g. Facebook graph api profile pics.
     * If a cached image is refreshed, the completion block is called once with the cached image and again with the final image.
     *
     * Use this flag only if you can't make your URLs static with embedded cache busting parameter.
     */
    SDWebImageRefreshCached = 1 << 4,

How to solve the problem in Kingfisher?


回答1:


Kingfisher has forceRefresh option to force downloading image again skiping cache

imageView.kf.setImage(with: url, options: [.forceRefresh])

refer this github thread for more details



来源:https://stackoverflow.com/questions/46702775/how-to-set-image-using-kingfisher-when-image-url-did-not-change-but-image-change

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