Search code examples
iosswiftcachingkingfisher

Swift App Termination removes Kingfisher Disk Cache


I'm having trouble with my kingfisher cache. The scenario: I save images from URL to a custom kingfisher cache.

When I read the given URL, it tells me that it first fetches the image from memory and after a few seconds, when refreshing, from disk. When I manually close the app and restart, on opening, kingfisher tells me that the cache disk size is for example 20MB. (This is what I expect)

Basically, the cache works perfectly all the time, except: When I move the app to the background it remains open for 5-30 minutes, until Apple/iOS kills it (Terminated due to signal 9) for memory reasons. When I start the app then, the cache (both memory and disk) is empty! How is that possible? What is the difference between the user and apple killing the application?


Solution

  • yes, this is possible. you can give a directory url like this: ImageCache(name: "test", cacheDirectoryURL: url) -> url could be your documents folder e.g.