Pipeline setup with `DataCache` is unnecessarily re-downloading original image for thumbnail request
Hello, I'm setting up my image pipeline like so:
var configuration = ImagePipeline.Configuration()
configuration.dataLoader = {
let config = URLSessionConfiguration.default
config.urlCache = nil
return DataLoader(configuration: config)
}()
configuration.dataCache = {
guard let containerURL = FileManager.default.containerURL(forSecurityApplicationGroupIdentifier: AppGroupIdentifier) else {
Log.error("Failed to initialize image pipeline data cache: Could not locate container URL")
return nil
}
let dataCachePath = containerURL.appendingPathComponent(ImageDataCacheName, isDirectory: true)
return try? DataCache(path: dataCachePath)
}()
configuration.dataCachePolicy = .storeAll
STEPS:
- Load a remote image with no processors and no thumbnail option (say request A)
- Load the same image with thumbnail option (request B)
RESULTS: Request B freshly downloads the original image again from the network.
EXPECTED:
I thought that since request A caused the cache to save the original image in the disk cache, that request B would be able to just retrieve that original and apply the thumbnail processing. Especially since I've passed .storeAll for the dataCachePolicy and request A has no processors or thumbnail option anyways.
NOTES:
Reading the code, it appears as though perhaps TaskFetchOriginalData should be checking the disk cache for an example of cached original image data before kicking off network activity. Thoughts?
I'm using DataCache and not the URLCache because in my app the images at a URL never change and I wanted to enjoy the performance benefits mentioned in the docs https://kean-docs.github.io/nuke/documentation/nuke/getting-started/. After noticing this issue though, it does occur to me that at least at the moment URLCache would seemingly do a better job of avoiding network activity since in this case the network request would be a cache hit.
Is there maybe something wrong with how I'm setting up the pipeline?
Thank you!