title: Node.JS: How does "fs.watchFile" work?
body: <p>According to the <a href="http://nodejs.org/docs/v0.4.3/api/fs.html#fs.watchFile" rel="noreferrer">API docs for Node 0.4.3</a>, the <code>fs.watchFile(filename, [options], listener)</code> function starts a routine that will</p>
  
  <blockquote>
    <p>Watch for changes on <code>filename</code>. The <code>callback</code> listener will be called each time the file is accessed.</p>
  </blockquote>
  
  <p>It also says</p>
  
  <blockquote>
    <p>The <code>options</code> if provided should be an object containing two members a boolean, <code>persistent</code>, and <code>interval</code>, a polling value in milliseconds</p>
  </blockquote>
  
  <p>Which indicates that it will check every so often based on what is in interval. But it also says</p>
  
  <blockquote>
    <p>The default is <code>{ persistent: true, interval: 0 }</code>.</p>
  </blockquote>
  
  <p>So does that mean it will check every millisecond to see if the file time changed? Does it listen for OS level events? How does that work?</p>