SDWebImage claims that AFNetworking doesn't cache the image itself but just the HTTP response, so SDWebImage is faster in recalling the image from cache and presenting it.
If I wanted to use purely AFNetworking, is such a claim, true or not, really something that is noticeable performance-wise? Is it something I should be wary of?
It's not true.
If you look at the code, you can see that the category UIImageView+AFNetworking
cache the UIImage
(using NSCache
and the urlRequest
as the key). The cache isn't written to disk though.
SDWebImage has much more control over image caching. It can cache to disk or memory.
AFNetworking relies on NSURLCache to persist images between app launches (and it's not very reliable), but it's great if you just need to cache during one run.
Both solutions cache a UIImage object in memory during the lifetime of the app. This is important because caching the NSData representation isn't fast enough to load images smoothly when scrolling through a table view.
Summary: AFNetworking's solution is simpler and will work for most use cases. If you need finer control, or disk caching, use SDWebImage instead of modifying AFNetworking's implementation.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With