I read somewhere a claim that Firebase caches the data.
So I ran this test that reads a semi large volume of data (about 400KB).
Here is the relevant code.
firebase.initializeApp(config);
var counter = 0;
console.time('firebase answered in');
firebase.database().ref('texts').once('value',onData);
function onData(snapshot){
console.timeEnd('firebase answered in');
counter ++;
if(counter > 20) return;
setTimeout(function(){
console.time('firebase answered in');
firebase.database().ref('texts').once('value',onData);
},2000);
}
As you can see, the first time it loads data it takes a while, and subsequent calls take much less time.
firebase answered in: 1279.422ms
firebase answered in: 236.378ms
firebase answered in: 228.595ms
firebase answered in: 202.700ms
firebase answered in: 208.371ms
firebase answered in: 214.807ms
etc
But, still, if the data is cached locally ~200ms
(sometimes more) seems like a lot of time to access local data. Enough for the user to perceive a delay when rendering the UI.
So is Firebase caching the data? What is happening in those ~200ms
?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…