title: Caching HTTP files with PHP
body: <p>I'm writing a library that requests files via HTTP and HTTPS. To reduce traffic to often requested URLs, I want to cache the retrieved files and respect their cache settings.</p>
  
  <p>Now the cache expiry seems to be a hard thing, because the <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.9" rel="nofollow">HTTP RFC</a> define so many of them that need to be checked in all possible combinations:</p>
  
  <ul>
  <li><code>Expires</code></li>
  <li><code>Cache-Control</code> (with dozens of possible values)</li>
  <li><code>Pragma</code></li>
  </ul>
  
  <p>I can imagine that someone already wrote PHP code that implements all that stuff correctly. Where is it?</p>