title: HTACCESS image caching rule that checks the image modification time
body: <p>I'm serving images two different ways:</p>
  
  <ol>
  <li>Using a PHP script for profile pictures for example</li>
  <li>By pointing to them directly, for icons and backgrounds for example</li>
  </ol>
  
  <p>I'm in the process of handling their caching properly, and i'm totally new to this.</p>
  
  <p>For the PHP script, i'm just adding a <code>Last-Modified</code> header to the response, and delivering a <code>304 status code</code> if it's called again, <strong>if the file hasn't changed</strong> (using <code>filemtime()</code>).</p>
  
  <p>For direct accesses, i'm using HTACCESS, but every rule i saw so far doesn't allow me to do the same as in my PHP script (checking if the file has changed, then serving a 304 or the file itself).</p>
  
  <p>Here's the HTACCESS rule i'm planning to use:</p>
  
  <pre><code>Header unset Pragma
  FileETag None
  Header unset ETag
  
  # cache images/pdf docs for 10 days
  &lt;FilesMatch "\.(ico|pdf|jpg|jpeg|png|gif)$"&gt;
    Header set Cache-Control "max-age=864000, public, must-revalidate"
    Header unset Last-Modified
  &lt;/FilesMatch&gt;
  </code></pre>
  
  <p>From what i understand, <strong>the only way of updating a cached image is to rename it.</strong> Does someone know a way around it? By checking the image's last modification date for instance?</p>