SDWebImage Download image and store to cache for key

后端 未结 11 1531
失恋的感觉
失恋的感觉 2020-12-24 03:30

Hello I am using the SDWebImage framework in a project and I want to download and cache images, but I think my code is storing an image in the cache twice? Is there any way

11条回答
  •  一个人的身影
    2020-12-24 04:04

    SDWebImage caches the image both to disk as well as memory. Let's go through this:

    1. You download the image from a new url.
    2. It gets cached to memory and disk.
    3. If you call the image in the same session, it is retrieved from the memory.
    4. Let's say you re-run the app and then access the url, it will check the memory, where the image won't be there, then it will check the disk, and get it from there. If not, it will download it.
    5. The image stays in disk for a week by the standard setting.

    So, you don't need to worry about caching. SDWebImage takes care of it pretty damn well.

    You can do custom implementation for caching as well as image refresh from the cache in case you want the settings as per your HTTP caching header as well.

    You can find the complete details on their github page here.

提交回复
热议问题