title: file_exists() is too slow in PHP. Can anyone suggest a faster alternative?
body: <p>When displaying images on our website, we check if the file exists with a call to <code>file_exists()</code>. We fall back to a dummy image if the file was missing.</p>
  
  <p>However, profiling has shown that this is the slowest part of generating our pages with <code>file_exists()</code> taking up to <strong>1/2 ms</strong> per file. We are only testing 40 or so files, but this still pushes <strong>20ms</strong> onto the page load time.</p>
  
  <p><strong>Can anyone suggest a way of making this go faster?</strong> Is there a better way of testing if the file is present? If I build a cache of some kind, how should I keep it in sync.</p>