Open adams-family opened 2 years ago
Using SDWebImageRefreshCached
may help with this. Which follows iOS system handling for HTTP E-Tag, etc.
And, you can actually update the image by yourself, get the cache path by -[SDWebImageManager cacheKeyForURL:]
, then update the disk cache using -[SDImageCache storeImageDataToDisk:forKey:]
@dreampiggy Thanks, SDWebImageRefreshCached
sounds like a perfect solution. Very nice!
@dreampiggy Sorry for the multiple comments... I think I struggle using SDWebImageRefreshCached
the right way.
I added this to my (SwiftUI) code:
WebImage(url: url, options: .refreshCached)
.onSuccess { image, data, cacheType in
switch cacheType {
case .all:
print(imageUrl, "cache = all")
case .disk:
print(imageUrl, "cache = disk")
case .memory:
print(imageUrl, "cache = memory")
case .none:
print(imageUrl, "cache = none")
default:
print(imageUrl, "cache = unknown")
}
}
The Etag
has changed on the file:
Before:
After:
However, the image does not change :( I still see "disk"
being printed on my debug console.
Hi @dreampiggy, great library!
I wanted to ask if it is possible to programmatically update images in disk cache in case that the original files have changed on the web? Maybe purge the cache once a week?
Thanks!