insin / react-hn

React-powered Hacker News client

Home Page:https://insin.github.io/react-hn

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Support caching comment-threads / page content offline

addyosmani opened this issue · comments

I previously added support for caching the react-hn application shell and static assets using Service Worker. This gave us a little bit of offline support, but the bigger missing piece here was caching comment threads and general responses coming back from the Firebase API. Let's fix that 🔧

Firebase's default offline support unfortunately only works during an individual session, so as soon as you close a tab or try relaunching the app from say - your Service Worker cache - it's still going to try reaching out to the network. This kills our ability to have comment pages fully work offline.

To address this, I've been working on a minimal read-only caching module that sits on top of Firebase that caches responses coming back from on(), once(), child() and so on using localForage (i.e IndexedDB in most modern browsers). I'll be PR'ing in a change that introduces this shortly.