title: Cant cache resource when having both gzip and Etag
body: <p>I am trying to cache a (javascript) resource in the browser and have properly set all of Cache-control:max-age, Expires, and Etag in the response headers (as is seen from the screenshot).</p>
  
  <p>The browser requests with "if-none-match" and "if-modified-since", and in both cases the conditions are met: </p>
  
  <ul>
  <li>if-modified-since = last-modified (the file has never been changed)</li>
  <li>if-none-match = Etag (again, the files has never been changed)</li>
  </ul>
  
  <p>So I should get response 304, right? But no, I keep getting 200 OK, which means that apache keeps serving the file (albeit compressed) every time. Tested with Firefox, Chrome, curl -- no use. Server always serves the whole file, even if I am not asking it to...</p>
  
  <p>Using curl, I have traced the problem to <strong>gzip &amp; Etag</strong>:</p>
  
  <ul>
  <li>if I remove the gzip (and cut the suffix -gzip from the request Etag) -- all is good: 304</li>
  <li>if I keep the gzip and remove the request Etag altogether -- all is good: 304</li>
  <li>but if I keep both 'accept-encoding:gzip' and the Etag, even though both request and response Etags are the same (this time with '-gzip' at the end), the server returns the wrong 200. It feels like apache compares the etag before gzipping the fail, decides it doesnt match, and then serves the file gzipped, even though after the gzip the Etag matches.</li>
  </ul>
  
  <p>Here is the request/response:</p>
  
  <ul>
  <li>Request Method:  GET</li>
  <li>Status Code:     <strong>HTTP/1.1 200 OK</strong></li>
  </ul>
  
  <p><strong>Request Headers 00:09:12.000</strong></p>
  
  <ul>
  <li>User-Agent:  Mozilla/5.0 (X11; Ubuntu; Linux i686; rv:36.0)
  Gecko/20100101 Firefox/36.0</li>
  <li>If-None-Match:   "24e55-51138062ce6c0-gzip"</li>
  <li>If-Modified-Since:   Sat, 14 Mar 2015 04:26:43 GMT</li>
  <li>Connection:  keep-alive</li>
  <li>Cache-Control:   max-age=0</li>
  <li>Accept-Language: en-US,en;q=0.5</li>
  <li>Accept-Encoding: gzip, deflate</li>
  <li>Accept:  <em>/</em></li>
  </ul>
  
  <p><strong>Response Headers Δ1100ms</strong></p>
  
  <ul>
  <li>Vary:    Accept-Encoding</li>
  <li>Server:  Apache/2.4.7 (Ubuntu)</li>
  <li>Last-Modified:   Sat, 14 Mar 2015 04:26:43 GMT</li>
  <li>Keep-Alive:  timeout=5, max=100</li>
  <li>Expires: Wed, 25 Mar 2015 16:09:13 GMT</li>
  <li>Etag:    "24e55-51138062ce6c0-gzip"</li>
  <li>Date:    Wed, 18 Mar 2015 16:09:13 GMT</li>
  <li>Content-Type:    application/javascript</li>
  <li>Content-Length:  53331</li>
  <li>Content-Encoding:    gzip</li>
  <li>Connection:  Keep-Alive</li>
  <li>Cache-Control:   max-age=604800</li>
  </ul>