Как установить изображение с помощью Kingfisher, когда URL-адрес изображения не изменился, но изображение изменилось

Как получить правильное изображение с помощью Kingfisher, когда URL-адрес изображения не изменился, но изображение изменилось, например, Twitter или GitHub.

SDWebImage имеет параметр [SDWebImageRefreshCached] для решения проблемы.

   /**
     * 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,

Как решить проблему в Kingfisher?


person ZhaoWei    schedule 12.10.2017    source источник


Ответы (1)


Kingfisher имеет параметр forceRefresh для принудительной загрузки изображения снова без кеша

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

обратитесь к этой ветке github для получения более подробной информации.

person Suhit Patil    schedule 12.10.2017
comment
Разве forceRefresh не будет загружать изображение каждый раз? - person PoolHallJunkie; 19.04.2018
comment
Обновляйте только тогда, когда приложение закроется, и перезапустите - person SPatel; 15.04.2021