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

Quick Question regarding Magic Mirror cache

Scheduled Pinned Locked Moved General Discussion
8 Posts 3 Posters 3.1k 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.
  • C Offline
    chef
    last edited by May 7, 2018, 1:14 PM

    Hi!
    Recently I have been using Magic Mirrors alert system, along with the RESTful(ish) Api to show an image from my home security camera.

    Example API POST request:

    "http://192.168.2.48:8080/api/v1/modules/alert/show_ALERT?timer=10500&imageUrl=http://192.168.2.18:9920/security/values/2&imageHeight=220px";
    
    

    Where the image is being served on a custom security web server.

    Everything is working quite nicely using the API module, however, it would seem that the magic mirror server is keeping an image in a cache and will repeat the same image over and over despite the POST request sending it a more current image.

    Is there a way to clear the Magic Mirrors cache?
    Perhaps a command I can send through the API prior to giving the Alert module the new image?

    I hope this question is making sense to the lead developers.

    I can go into more detail and explain the workflow further if this isn’t making sense to anyone.

    Many thanks!

    1 Reply Last reply Reply Quote 1
    • C Offline
      chef
      last edited by May 7, 2018, 2:16 PM

      Upon further research, perhaps it is Electron which is cache the image.

      And I might be wrong but it looks as though clearing cache has to happen in the core of the application.

      Something like “session.Clear()”

      N 1 Reply Last reply May 8, 2018, 5:44 PM Reply Quote 1
      • E Offline
        E3V3A
        last edited by May 8, 2018, 6:51 AM

        This is a very interesting question!

        I have been thinking about all those calls to the font-awesome site that is (probably?) being continually generated every time a module refreshes. Just to re-fetch the same few icons… Seem crazy to me.

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

        C 1 Reply Last reply May 13, 2018, 2:51 PM Reply Quote 0
        • N Offline
          ninjabreadman @chef
          last edited by May 8, 2018, 5:44 PM

          @chef The POST request isn’t sending it an image, it’s sending the URL to the image (e.g. http://192.168.2.18:9920/security/values/2). The problem is, it already has a cached copy of that image. I suggest you append a timestamp to trick electron into re-fetching the same image/resource.

          You want to pass it a URL-encoded value, so use %3F as ? and just append your timestamp, like so:

          http://192.168.2.48:8080/api/v1/modules/alert/show_ALERT?timer=10500&imageUrl=http://192.168.2.18:9920/security/values/2%3F
          {INSERT TIMESTAMP HERE}&imageHeight=220px
          

          Problem with config or JavaScript? Copy/paste it into JSHint.
          Check out the detailed walkthroughs on install, config, modules, etc.

          1 Reply Last reply Reply Quote 2
          • C Offline
            chef
            last edited by May 13, 2018, 2:46 PM

            @ninjabreadman said in Quick Question regarding Magic Mirror cache:

            http://192.168.2.48:8080/api/v1/modules/alert/show_ALERT?timer=10500&imageUrl=http://192.168.2.18:9920/security/values/2%3F
            {INSERT TIMESTAMP HERE}&imageHeight=220px

            Thaaaaank you sir! absolutely spot on! Now Alexa will describe the person in the security image (using M$ cognitive sense API), and the mirror in the kitchen flashes the security image as an alert.

            Pretty bad@$$ actually!

            1 Reply Last reply Reply Quote 0
            • C Offline
              chef @E3V3A
              last edited by May 13, 2018, 2:51 PM

              @e3v3a so it would seem that the cache is in place to keep those images from a constant request situation.

              However, now that you mention using FA icons on the alerts; I wasn’t able to successfully request FA images in my alerts.

              Do you have an example of how you are doing it I could see?

              1 Reply Last reply Reply Quote 0
              • E Offline
                E3V3A
                last edited by May 14, 2018, 8:07 AM

                @chef
                You project sound awesome! IS it private, or will you share it with us?

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

                C 1 Reply Last reply May 14, 2018, 11:40 AM Reply Quote 0
                • C Offline
                  chef @E3V3A
                  last edited by May 14, 2018, 11:40 AM

                  @e3v3a Sure I can share it!

                  There is a bit of a setup to get things rolling, but in the end, the security camera/alexa/Cognitive neural network is quite on point.

                  The best part is that if the neural network does get confused, the image is sent to the magic mirror anyway. So, Alexa will apologize for not being able to gather image information but will remind you to look at the magic mirror alert.

                  However, in both instances, the security camera image is posted on the mirror.

                  1 Reply Last reply Reply Quote 0
                  • 1 / 1
                  1 / 1
                  • First post
                    1/8
                    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