1

Im woking with swift. My database setup.

In my database I am saving the URL to the stored image in Firebase storage.

I then use the URL to download and update UIImageviews which works nicely

However, I have tried using SDWebImage and kingfisher to cache and manage storage but both have give me the same issue. They will store the image in memory but not to disk. So after some time, the app needs to redownload the image which isn’t idea for offline capabilities.

I have tried changing the cache control header by extending the max age but with out any change.

I have also used the file manager system to store the image to disk myself which also works.

So I’m a little stuck any help ?

bradmuzza
  • 41
  • 1
  • 2
  • 8
  • It's challenging to understand the question or the actual issue. The question states that *images caching to memory but not disk* but then in your description states you can store the images to disk. Can you clarify the question? It's also a good idea to include code per the guide. Please take a moment and review [How do I ask a good question?](https://stackoverflow.com/help/how-to-ask) and [How to create a Minimal, Complete, and Verifiable example](https://stackoverflow.com/help/mcve) – Jay Aug 24 '18 at 17:53
  • Updated the question to hopefully be more clear... I’m not sure what code I would add in this situation. Any directions would be helpful – bradmuzza Aug 24 '18 at 20:26
  • Why are you downloading and storing to disk? Typically a array used as a dataSource would be populated with Firebase data which makes it fast and responsive. If there's a lot of data, it would be paginated so only the data within the viewable area is downloaded. I think the use-case is what's missing and along with that the code you are trying to implement. – Jay Aug 24 '18 at 21:12
  • Maybe this is my issue. I was under the understanding that these libraries(sdwebimage and kingfisher) fall back to disk after memory. For example, check memory first, if the image isn’t there then check disk, if image is not on disk then download from the Firebase. My users will be accessing the image when offline. Currently, when I test my app, if I leave my app for sometime and turn connectivity off, no images are shown to the uses. Apologies for the lack of clarity, I have been grappling with this issue for two weeks and it’s really had to debug. – bradmuzza Aug 24 '18 at 21:26
  • I don't think you need those libraries. Firebase also provides [offline persistence](https://firebase.google.com/docs/database/ios/offline-capabilities) for the times when the internet connection is interrupted. Keep in mind that Firebase is geared toward an online experience so if you are doing a lot of offline work, Firebase may not be the best total database solution. – Jay Aug 24 '18 at 21:39
  • The database persistence works fine for my use case. The images from the Firebase storage does not. I was unaware that storage also had persistence hence my use of sdwebimage etc – bradmuzza Aug 24 '18 at 21:51
  • I wasn't really thinking persistence of Storage but it really depends on your use case. It sounds like you are doing a lot of offline work. – Jay Aug 24 '18 at 22:04

0 Answers0