Question about Meteor internals and server-side calls to the database


#1

Hi,

When a new subscription comes in for a publication that the server is already handling, no new call is made to the database, but the data already cached on the server is used to respond to the client. Is this correct?

Does this caching mechanism work for all server side calls? If one were to make a call to the database and all the data is already cached on the server, would Meteor query Mongo directly or would it simply use the cached data. And if it does use the cached data, how does it know all the data is already on the server?

I’m wondering if it’s worth caching a mostly static collection of 700 documents on the server to avoid unnecessary calls to the database, or whether Meteor already does this for me.


#2

Meteor only does this for live queries. So if you return a db cursor from a publication, or observe the cursor, then the data is cached. But if you just do a findOne in a method or something, it won’t be.

That’s because Meteor only knows the data is fresh if it’s running a live query on it.