I have a product page with all my product and every time someone presses F5 it get executed. I want to save all de product but when a product is added it can get update once to reduce all the api calls.
- I tried to save it in Cookie, but that is nog a nice way.
I tried to do it with Http cache-control but it dit not work (How to save firestore requests by using Http cache-control?)
I tried localstorage, but it did get not executed when a new product is added.
//JS file My cookie try: it works i only get a api call every 0.5 days but if a update happens in my product i only get is later
//if cookie === undifined
const firestore = firebase.firestore()
firestore.doc("products/phones").onSnapshot(function (doc) {
if (doc && doc.exists) {
const products = doc.data().produc
//Save doc.data().produc in cookie 0.5 day expirery
}
})
I want to save my Firestore request client side and only make a Firestore request when needed to update the product list.