title: 5-minute file cache in PHP
body: <p>I have a very simple question: what is the best way to download a file in PHP but only if a local version has been downloaded more than 5 minute ago?</p>
  
  <p>In my actual case I would like to get data from a remotely hosted csv file, for which I currently use</p>
  
  <pre><code>$file = file_get_contents($url);
  </code></pre>
  
  <p>without any local copy or caching. What is the simplest way to convert this into a cached version, where the end result doesn't change ($file stays the same), but it uses a local copy if it’s been fetched not so long ago (say 5 minute)?</p>