title: Watching files for changes on Vagrant, file modification times not updating
body: <p>We're trying out Vagrant. We have a web application directory on the host shared with the guest via NFS. While developing the website we quickly started to hit issues.</p>
  
  <p>We are running gulp-watch to spot changes to stylesheet and javascript files and run tasks, but changes were not being picked up for up to one minute.</p>
  
  <p>Also, Laravel was not noticing that blade templates were being changed, and so was not recompiling them and the old view templates were being shown.</p>
  
  <p>I eventually boiled down the problem to a very short PHP script to demonstrate the error.</p>
  
  <pre><code>&lt;?php
  header('Content-Type: text/plain');
  $file = 'test.html';
  
  echo "modified: " . date('r', filemtime($file)) . "\n";
  echo "contents: " . file_get_contents($file) . "\n";
  </code></pre>
  
  <p>This gets the modification time of another file <code>test.html</code> and also outputs its contents. This gave strange behaviour. When changing <code>test.html</code> (incrementing its full contents, a single integer) via the host and then refreshing the page, either it would work as expected (new file modification date, and the new file contents) or the contents of the file would update but the file modification date would not. On hitting refresh the modification date would then catch up. Here's an example of the latter case.</p>
  
  <p><img src="https://i.imgur.com/5hawZHd.gif" alt="Demonstration"></p>
  
  <p>I later found that if the "modified" and "contents" lines were switched around so that the contents were retrieved before looking at the modification date, I would get the expected output every time.</p>
  
  <p>The question was what was causing this and how we could get around it, and was it linked to the issues with watching files for changes?</p>