I noticed some interesting behavior with while developing my MMM-Surf module. I observed this behavior after I added a “last updated” timestamp at the bottom of the UI. If the MagicMirror software is loaded from different clients (e.g. RPI with screen + web client), each will have a different last updated timestamp. So let’s say I load the RPI+Screen client + 3 web clients, each a minute apart. That will produce 4 unique API requests upon load and then 4 unique API requests when the update window is triggered on each client.
Is anyone aware of a way to cache data that is rendered to the UI and hold it for, say, the same timeframe as the update window? This could help reduce hitting API sources and keep things synched across the clients.
Thanks in advance!
Put the API request in node_helper.js. MMM-Surf.js is run on client and node_helper.js on server. Keep in mind that there is always only one node_helper instance.
@retroflex - that is where all of my API requests reside. MMM-Surf calls the node_helper functions. Whenever the app is loaded it makes new calls.
I am looking into node-cache to see if I can integrate that somehow.
E3V3A last edited by
yeah , you need to save it with a
thisthing. Someone helped me fix this here. So you probably need to do something very similar. (Save the current data, and restore it when someone is trying to use it before the timeout.)
@E3V3A that worked perfectly. Thank you for sharing!