SDWebImage 預設是暴力快取。
只要載入過的圖檔都會被強制快取在本地端,
除非把程式移除,不然不會更新快取。
優點是效能非常好,就算離線狀態也能顯示。
缺點是當圖檔更新的時候,不會跟著更新。
[uiimageview setImageWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"http://lorempixel.com/400/200/cats/%d", 1+indexPath.row%9]] placeholderImage:[UIImage imageNamed:@"previewholder"]];
SDWebImageRefreshCached: 依照 HTTP Caching Control Header 來更新圖檔。
[uiimageview setImageWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"http://lorempixel.com/400/200/cats/%d", 1+indexPath.row%9]] placeholderImage:[UIImage imageNamed:@"previewholder"] options:SDWebImageRefreshCached];
To clean both memory and disk cache.
SDImageCache *imageCache = [SDImageCache sharedImageCache];
[imageCache clearMemory];
[imageCache clearDisk];
[imageCache cleanDisk];