title: How prevent browser from caching XML file served by Apache? (My htaccess file is included)
body: <p><strong>UPDATE 2</strong></p>
  
  <p>I discovered the answer but I'm not sure why it's required and how to change this behavior in Apache.</p>
  
  <p>If I <code>unlink</code> (i.e. delete) the XML file first and then recreate it (instead of just writing over it), then <em>both</em> browsers see the fresh version!</p>
  
  <pre><code>//This causes a fresh version
  unlink( $xmlFileLocation );
  
  //Now creating it will result in a non-cached version being sent
  $f = fopen( $xmlFileLocation, "wb" );
  fwrite(, $xmlFileLocation, $xml );
  fclose( $xmlFileLocation );
  </code></pre>
  
  <p>If I do the above without <code>unlink</code>, then it gets changed and the modified date <strong>is</strong> updated on disk, but Apache continues to serve the old version!! Why?</p>
  
  <p><strong>UPDATE 1 - problem still happening despite mod_headers enabled!</strong></p>
  
  <p>I <em>thought</em> I needed to enable the module mod_headers. </p>
  
  <pre><code>sudo a2enmod headers
  </code></pre>
  
  <p>but both Chrome and Firefox still appear to be getting old versions of the XML file!</p>
  
  <p>What could be causing Apache to continue to serve the old version? (Clearing the browser cache did not help and the file on disk IS different from what gets seen in both browsers)</p>
  
  <p><strong>Original POST</strong></p>
  
  <p>I'm trying to stop the browser from caching the XML files I'm serving up but it's not working. When I view the file on the computer itself, it shows it is updated, but in the browser (Chrome and Firefox) it shows as the old version!</p>
  
  <p>I am certain my htaccess which is located in the XML file folder is working (I tested by changing it to <code>deny from all</code> and it correctly showed a <code>"Forbidden"</code> response).</p>
  
  <p><strong>.htaccess</strong></p>
  
  <pre><code>&lt;FilesMatch ".(xml)$"&gt;
  FileETag None
  &lt;ifModule mod_headers.c&gt;
  Header unset ETag
  Header set Cache-Control "max-age=0, no-cache, no-store, must-revalidate"
  Header set Pragma "no-cache"
  Header set Expires "Wed, 11 Jan 1984 05:00:00 GMT"
  &lt;/ifModule&gt;
  &lt;/FilesMatch&gt;
  </code></pre>
  
  <p>This does not stop the caching! What else can I do?</p>
  
  <p><strong>EDIT</strong> I'm not sure, but I think Apache might be caching it server-side! How would I diagnose and stop that? </p>
  
  <p>I <em>think</em> that's the case due to Chrome showing the request headers:</p>
  
  <pre><code>Accept:text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
  Accept-Charset:ISO-8859-1,utf-8;q=0.7,*;q=0.3
  Accept-Encoding:gzip,deflate,sdch
  Accept-Language:en-US,en;q=0.8
  Cache-Control:no-cache
  Connection:keep-alive
  Host:mywebsite.com
  Pragma:no-cache
  </code></pre>
  
  <p>yet it still shows the cached version!</p>