iossdwebimage

SDWebImage change cacheMaxCacheAge


How I can change a static value cacheMaxCacheAge when I use SDWebImage? What way is good? I need to cache images for 5 minutes.


Solution

  • In SDWebImage 5.0+ maxCacheAge renamed to maxDiskAge. You can set maximum caching time in seconds like this.

    Objetive-c

    [SDImageCache sharedImageCache].config.maxDiskAge = 60 * 5; //5 minutes
    

    Swift 4+

    SDImageCache.shared.config.maxDiskAge = 60 * 5 //5 minutes
    

    Reference link: https://github.com/SDWebImage/SDWebImage/wiki/5.0-Migration-guide