title: How to check if a file exists and is modified recently enough?
body: <p>I want to implement a simple file caching mechanism with Node.js. To that end, I need to checks if a recently modified file exists under a given path. I have some code that returns the last modified time of the file following <a href="https://stackoverflow.com/questions/7559555/last-modified-file-date-in-node-js">this question</a>. How do I use the <code>mtime</code> object to check if the file is recent enough, for example, no older than 24 hours?</p>
  <pre><code>const fs = require('fs');
  
  function have_recent_file(path)
  {
      try {
          const mtime = fs.statSync(path).mtime;
          /*
           TODO: return true if the file is modified in the last 24 hours
          */
      } catch (ex) {
          return false; // file does not exist or is not accessible
      }
  }
  </code></pre>