nalexn / clean-architecture-swiftui

SwiftUI sample app using Clean Architecture. Examples of working with CoreData persistence, networking, dependency injection, unit testing, and more.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Image caching

NeverwinterMoon opened this issue · comments

Hi!

Some time ago, you've swapped your own implementation of file/in memory caching in favour of URLSessionConfiguration caching.

The latter approach does not work that well in some cases. Say, the image was missing at some specific URL (maybe the server was down), the data is returned (for instance, it was an error page) and is cached. This data couldn't be converted to image (UIImage(data: data)), still, every next load invocation will have wrong cached data and won't try to check if there is a valid data present.

Maybe it makes sense to manage the same URLCache but manually using CachedURLResponse, instead of using .returnCacheDataElseLoad?

Hey @NeverwinterMoon ,
Thanks for pointing out to this interesting edge case, I've implemented a fix.