Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Accessing Files from Firebase Storage vs Firebase Hosting?

So here is the scenario:
When I access files from Firebase Storage:

  1. I get my file from storage bucket(.html, .png, .zip etc) (Small in size btw no more than 2mb).
  2. Store that file in my local storage so the app don't need to download it again and consume the bandwidth of the server.
  3. Use it from local storage everytime the app needs it.

When I access files from Firebase Hosting:

  1. I get my file from nearest CDN of Firebase(.html, .png, .zip etc) (Small in size btw no more than 2mb).

  2. Store that file in my local storage so the app don't need to download it again and consume the bandwidth of the server.

  3. Use it from local storage everytime the app needs it.

NOTE: I also have one file version.txt on storage bucket (Firebase Storage). According to the value in this file, I decide whether to fetch file in Step 1 again or not. It means the version.txt is fetched everytime.

Questions:

  1. How to achieve the similar version programming part in Firebase Hosting? I know we deploy folders, can we get their version from Firebase CDN. If yes, how?
  2. In which method I gonna first hit my LIMIT as we know Firebase is paid after a limit.

Pros of Hosting: It will be faster. Link

PS:
1. My concern is bandwidth and not security.

  1. Currently, I am using basic Plan (free) with limits Source:

Hosting Plan Details Storage Plan Details

like image 224
Ishaan Kumar Avatar asked Oct 27 '17 11:10

Ishaan Kumar


People also ask

How do I retrieve files from Firebase Storage?

There are two ways to download files with Firebase Storage, using references in the SDK or a download URL. iOS and Android users can download files into memory, disk, or from a download URL. The web SDK can download files just from a download URL. StorageReference storageRef = FirebaseStorage.

Why should I use Firebase Hosting?

Firebase Hosting has lightweight hosting configuration options for you to build sophisticated PWAs. You can easily rewrite URLs for client-side routing, set up custom headers, and even serve localized content.

Is Firebase Storage same as Google Cloud Storage?

The new Firebase Storage is powered by Google Cloud Storage, giving it massive scalability and allowing stored files to be easily accessed by other projects running on Google Cloud Platform. Firebase now uses the same underlying account system as GCP, which means you can use any GCP product with your Firebase app.

Where do Firebase files go?

Firebase uploads files to the Google Cloud Storage (part of the Google Cloud Platform. Unless configured otherwise, the files that are uploaded to Cloud Storage will also be accessible by App Engine; both pieces share the same buckets.


1 Answers

From the Firebase docs:

  • The Firebase Realtime Database stores JSON application data, like game state or chat messages, and synchronizes changes instantly across all connected devices.
  • Firebase Remote Config stores developer-specified key-value pairs to change the behavior and appearance of your app without requiring users to download an update.
  • Firebase Hosting hosts the HTML, CSS, and JavaScript for your website as well as other developer-provided assets like graphics, fonts, and icons.
  • Cloud Storage stores files such as images, videos, and audio as well as other user-generated content.

Storage has higher free tier limits, while Hosting might be a little faster. Note that all files on Hosting are publicly accessible, so if you need authentication or authorization, you should use Storage.

like image 96
Mike McDonald Avatar answered Nov 12 '22 04:11

Mike McDonald