MagicMirror Forum

    • Register
    • Login
    • Search
    • Recent
    • Tags
    • Unsolved
    • Solved
    • MagicMirror² Repository
    • Documentation
    • Donate
    • Discord
    MagicMirror² v2.20.0 is available! For more information about this release, check out this topic.

    UI/Data Caching

    Troubleshooting
    3
    5
    1121
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • P
      Privacywonk last edited by

      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!

      1 Reply Last reply Reply Quote 0
      • R
        retroflex Project Sponsor Module Developer last edited by

        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.

        1 Reply Last reply Reply Quote 0
        • P
          Privacywonk last edited by

          @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.

          1 Reply Last reply Reply Quote 0
          • E
            E3V3A last edited by

            yeah , you need to save it with a this thing. 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.)

            "Everything I do (here) is for free – altruism is the way!"
            MMM-FlightsAbove, MMM-Tabulator, MMM-Assistant (co-maintainer)

            1 Reply Last reply Reply Quote 1
            • P
              Privacywonk last edited by

              @E3V3A that worked perfectly. Thank you for sharing!

              1 Reply Last reply Reply Quote 1
              • 1 / 1
              • First post
                Last post
              Enjoying MagicMirror? Please consider a donation!
              MagicMirror created by Michael Teeuw.
              Forum managed by Paul-Vincent Roll and Rodrigo Ramírez Norambuena.
              This forum is using NodeBB as its core | Contributors
              Contact | Privacy Policy