What happens to SDWebImage Cached Images in my app when the image file on the server changes?

后端 未结 10 1247
夕颜
夕颜 2020-12-07 09:57

I am using the SDWebImage library to cache web images in my app:

https://github.com/rs/SDWebImage/blob/master/README.md

Current Usage:



        
10条回答
  •  忘掉有多难
    2020-12-07 10:15

    I had a look at the source code. It processes the setImageWithURL method like this:

    1. Ask the memory cache if the image is there, if yes return the image and don't go any further
    2. Ask the disk cache if the image is there, if yes return the image and don't go any further
    3. Try to download the image, return image on success else keep the placeholder image

    There is no request sent to ask the remote server if there is a new version while there is something old on disk, like using ETags of the HTTP protocol.

    Digging a bit deeper the cache time is set to a static value in SDImageCache.m

    static NSInteger cacheMaxCacheAge = 60*60*24*7; // 1 week
    

    it cannot be changed with a setter.

    So as long as the image in the cache is valid the SDWebImage lib won't download anything new. After a week it'll download your changed image.

提交回复
热议问题