Static publish optimizations


I am new to meteor so I want to make sure I’m not doing something stupid.
I have a few collections that doesn’t change (or even if they do the client shold not receive the updates) during an user session.

If I cache the cursors on the server side

let cache = [collection.find({}), collection2.find({})];
 return cache;

It would avoid making new mongo queries for each client subscription? I realise if I do update the datatabase I need to reset the cache too.

Can I do other improvements? I use “reactive:false” on the client side too.


instead of using publish i think you could try using method or package call ReactiveMethod (is not reactive it is just help you get data to the helper without call back)

Thanks, can cursors be fetched from client trough a Metheor.method ?

Not cursors, but it does return arrays. You will need to to do something like this:

    firstCollectionData() {
        return collection.find({}).fetch(); //.fetch() returns an array from the cursor
    secondCollectionData() {
        return collection2.find({}).fetch(); //.fetch() returns an array from the cursor
1 Like