Ancinek Ancinek - 4 months ago 26x
iOS Question

Firebase - downloading few files

Is there a way to download couple of files (images) using Firebase Storage SDK and live cache those files, so after an image is downloaded the cache is updated?

Can I also observe in another view controller for this cache being updated?

I don't need a whole answer, just maybe a hint where to learn it. I've search through firebase documentation, found some info but I have absolutely no idea how to use it.


Take a look at NSURLCache. Basically what you'll do is, every time you upload a file to Firebase Storage, you can get a download URL and download it, then storeCachedResponse:forRequest: in the URL cache. Since this cache is shared, you can even grab it across activities.

Similarly, on download, you'll want to check for the cached request via cachedResponseForRequest: and if it doesn't exist, perform the download (at which point you cache the request for later).

Long term, we're hoping to enable this behavior for you out of the box, but for now, you can use NSURLCache to make it happen :)