• Recent
  • Tags
  • Unsolved
  • Solved
  • MagicMirror² Repository
  • Documentation
  • 3rd-Party-Modules
  • Donate
  • Discord
  • Register
  • Login
MagicMirror Forum
  • Recent
  • Tags
  • Unsolved
  • Solved
  • MagicMirror² Repository
  • Documentation
  • 3rd-Party-Modules
  • Donate
  • Discord
  • Register
  • Login
A New Chapter for MagicMirror: The Community Takes the Lead
Read the statement by Michael Teeuw here.

UI/Data Caching

Scheduled Pinned Locked Moved Troubleshooting
5 Posts 3 Posters 1.6k Views 3 Watching
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 Offline
    Privacywonk
    last edited by Apr 14, 2018, 4:23 PM

    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 Offline
      retroflex Project Sponsor Module Developer
      last edited by Apr 14, 2018, 6:55 PM

      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 Offline
        Privacywonk
        last edited by Apr 14, 2018, 8:47 PM

        @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 Offline
          E3V3A
          last edited by Apr 14, 2018, 9:08 PM

          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 Offline
            Privacywonk
            last edited by Apr 22, 2018, 12:20 PM

            @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 Sam, technical setup by Karsten.
            This forum is using NodeBB as its core | Contributors
            Contact | Privacy Policy