Will meteor server cache same publications with same params?

if many clients subscribe to the same one publication with same params, will meteor server run only one publication task for all of them, or one for each?

It will not cache the data in memory or on another data store (redis, memcached), but the realtime analysis of the oplog will be done once per publication and then send the data that changed back to all subscribed clients.

That’s why it is recommended to design your publications so they can be used by many clients and it is discouraged to have client’s specific publications (unless there isn’t really another choice, example of a notification system : Meteor.publish(‘myNotifications’, function () { return Notifications.find({userId: this.userId});

thanks, it’s very helpful

So are you saying that if I have a page listing a number of widgets, and a publication that publishes all those widgets (for the currently authenticated user) and another page that is a ‘show’ page for detail on one of those widgets that I shouldn’t have a publication for the latter scoped by the ID of the widget?

I should have an identical subscription for an index and show page and just use MiniMongo to get the data I need? What happens if the client refreshes the show page? The data for all widgets will be sent, though only one record is required.

That’s why it is recommended to design your publications so they can be used by many clients

Do you have a reference for that? Interested to learn more. :smile:

Yes, that is what I learned by experience. Those kind of small optimisations can make your app way more scalable.
You can also create publications and disabling op-log on them, so you can still have the same code/logic (so you can still populate your minimongo).

I don’t remember a source for my advice, but if I find one, I’ll send it here :smile:

Gotcha. Thanks for the reply.