Skip to content
This repository has been archived by the owner on Jan 23, 2021. It is now read-only.

Using Sw-precache with firebase (question) #165

Closed
jasan-s opened this issue Sep 3, 2016 · 3 comments
Closed

Using Sw-precache with firebase (question) #165

jasan-s opened this issue Sep 3, 2016 · 3 comments

Comments

@jasan-s
Copy link

jasan-s commented Sep 3, 2016

I am a bit unclear as to how to configure runtime caching option for my SPA so that I can have service worker control calls made to firebase database for data and cache the previously downloaded dynamic data beacuse on refresh the data disappers(when no network) . Any help would be greatly appreciated.

I don't know if its better to use something like redux-persist which saves the last state in memory so state persists through refresh. but the problem with that is if there is a change in data, how would i know?

@jeffposnick
Copy link
Contributor

You can't, really, if you're using the Firebase Web Socket interface. Web Socket calls bypass the service worker completely.

If you are using the REST interface, then it's possible to have the service worker intercept those calls, but it's not necessarily going to be the best approach (and it forces you to use REST instead of the realtime API).

Instead, what I'd recommend doing is using IndexedDB to handle offline scenarios. Unfortunately, this isn't officially baked into the Firebase JavaScript SDK at the moment, so you'll have to roll your own solution.

https://www.youtube.com/watch?v=srdKq0DckXQ is @addyosmani's talk from Google I/O 2016, that goes into some detail on how he accomplished this in a sample app. You can also take a look at the open source code for the Google I/O Web App, which implements IndexedDB queueing for all read and write operations to handle offline scenarios: https://github.com/GoogleChrome/ioweb2016/blob/master/app/scripts/helper/firebase.js

@Sliqric7053
Copy link

Sliqric7053 commented Jun 13, 2018

Hi guys
Is the original issue still the case? Or has someone found a work-around?
I am experiencing the same issue.

I have the same problem as the asker of this question (https://www.stackoverflow.com/questions/50574401/service-worker-not-working-for-external-images-only ), Specifically, I’ve stored my images on Firebase Storage, the access url of which I’ve inserted as a property (i.e. logo-url) into my “members” collection (in Firestore), which I call from a service in Angular 6 and subscribe to it in one of the components. How can I get my Service Worker (ngsw) to cache these images?

@aSegatto
Copy link

aSegatto commented Aug 2, 2018

same problem here, the sw is not caching the images on the storage....

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants