firebase / firebase/firebase-ios-sdk

FR: Skip re-downloading files from Storage

Open
#9,231 4 comments 2 reactions 1 assignee Assigned to @abhis3 View on GitHub
api: storage type: feature request
Dominant language
C++
Stars
6.7k
Forks
1.8k
Avg merge
2d 18h
Merged PRs (30d)
75

Description

### Feature proposal

* Firebase Component: Storage

When using [`writeToFile`](https://firebase.google.com/docs/reference/ios/firebasestorage/api/reference/Classes/FIRStorageReference#-writetofile:completion:), a file is alway downloaded fresh from the Storage. In my app, I download a lot of files and most of them are unchanged. Which results in a lot of traffic. I was getting files from S3 previously and used following caching strategy to speed things up:
1. When a file is downloaded, get the value of `Etag` head field
2. Save the `Etag` values as extended attribute (using `setxattr()`) with `XATTR_FLAG_CONTENT_DEPENDENT` flag
3. When the file is downloaded again, get the `Etag` extended attribute
4. If the attribute is present, set header `If-None-Match` to the etag value
5. If server returns `304`, treat it as success

Since the Storage APIs hide the HTTP headers and response codes, I can not implement this strategy in my code. I am proposing to add a option `checkEtgBeforeDownload` and implement this algorithm within Firebase SDK.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.