So I'm building this web app that connects software engineers looking for work with recruiters, and I have a chat component where recruiters can get in touch with potential candidates.
It's a pretty basic JavaScript (Nuxt.js) front-end with Firebase as back-end. I'd rather not pull all chats and all messages every time a user goes to the chat page, or even once per login. So I was wondering what conventions exist to solve something like this?
I'm thinking of putting the chat data in either localStorage or IndexedDB, and only grab new entries from the back-end when needed. Though I feel a bit iffy about storing chat messages like that.
Does anyone have experience with something like this?
Firestore can do the caching for you if you configure persist
You can order by time and limit with a custom index
You should always save data by the reader not normalised like with DBMS
This is the correct answer.
https://firebase.google.com/docs/firestore/manage-data/enable-offline
It's as simple as:
firebase.firestore().enablePersistence();I believe Firebase uses IndexedDB to cache queries, so don't re-invent the wheel here.
+1.
+1 to this; we're experimenting with GCP / chat.