-
Notifications
You must be signed in to change notification settings - Fork 0
FAQ
Please check whether you are trying to access with an image resource with "http" scheme. If so, you need to switch to "https" or disable ATS in your Info.plist.
Kingfisher is using an aggressive cache policy by default. It will put all loaded image into NSCache and will not purge it unless a memory warning is received. In general, it is fine and we could take use all available resources to enhance user experience. There should be nothing to worry about.
However, if you need to keep a small memory footprint, you could limit the memory cache used by setting the maxMemoryCost of ImageCache.default to a small value. For example, this will "disable" the memory cache:
ImageCache.default.maxMemoryCost = 1Or you could call ImageCache.default.clearMemoryCache() when necessary (before you need to do some memory consuming operation). This will free the memory cache, so you could avoid a memory using peak.
Kingfisher is using a hashed the url absolute string for cache key by default. So if your url changes, even only the query part or timestamp, Kingfisher will think that it is a new image which is not cached yet.
Yes, but it is not built-in supported in Kingfisher. You may need to implement your own ImageProcessor and CacheSerializer. It is also already done by some other libraries, for example, KingfisherWebP. For more discussion on this topic, search for "webp" in the issues.
Yes. You could setup an ImageDownloadRequestModifier and pass it in option to modify the request header. It is useful when you are doing a basic HTTP authentication or any token based authentication. If you are using some certification, please set authenticationChallengeResponder of ImageDownloader and implement your auth logic in the delegate method.
Sometimes you are not doing UI things and just want the image. You could use KingfisherManager for it:
KingfisherManager.shared.retrieveImage(with: url) {
(image, error, cacheType, url) in
if let image = image {
// Use image
}
}This will check the cache first, if the image is not cached yet, it will download it from given url. If you need more control of it, use ImageDownloader and ImageCache instead.