Non-reactive pages


Say if i am making a site with many static pages with a lot of traffic, it would be wise to serve the collection data to these pages only once when the page is rendered. Since the static content updates are very infrequent, there would be no reason to have a constant connection between client and server and it will save a lot of memory.

I know there is a non-reactive option when you do collection.find({…non-reactive: true}), does this actually terminate the connection between client and server and saves memory? or does it simply prevents update in the DOM but data is still being sent down to the client?


No, it does not. The connection depends on if you have any publications going. Or rather, the connection is on by default, but it doesn’t do anything and doesn’t take up any memory on the server related to keeping track of what data is on each client, if you don’t subscribe to any publications on the client.

So this is what {reactive:false} does.

In order to actually not use any unnecessary server resouces for data that is basically static, you have to find ways to send data to the client without using pub/sub.
One way is to use Meteor methods, but then the app has to wait for the initial data to arrive, which is not ideal. And I think there must be some way of injecting initial data on the server. The meteorhacks:fast-render package might contain hints as to how that can be accomplished. I personally haven’t bothered with that kind of optimization yet, but I will want to introduce it at some point as static data is often something that I do need in my apps!

HTH & share if you find out about good ways to accomplish this!


Gotcha, yea i think meteor methods is probably the best way here.


For only static content maybe some kind of REST API would be more appropriate for that usecase.

BTW when talking about find reactive false, how it will behave set in publication if it is possible