title: Indefinitely caching a HTTP response via Nginx fails
body: <p>I'm trying to tell nginx to cache some of my assets (js, css) forever, or at least for a very long time.</p>
  
  <p>The idea is that once an asset bundle is compiled and published with an <code>/assets/</code> URI prefix  (e.g. <code>/assets/foo-{fingerprint}.js</code>) it stays there and doesn't ever need to change.</p>
  
  <p>The internets told me I should write the following rule:</p>
  
  <pre><code>location ~ ^/assets/.*-([^.]+)\.(js|css)$ {
    gzip_static on; # there's also a .gz of the asset
    expires max;
    add_header Cache-Control public;
    add_header Last-Modified "";
    add_header ETag "";
    break;
  }
  </code></pre>
  
  <p>I would expect this would result in responses with HTTP code 304 "Not Modified", but what I get is a consistent HTTP 200 (OK) every time.</p>
  
  <p>I have tried some other approaches, for instance:</p>
  
  <p>a) explicitly setting modification time to a constant point in time in the past;</p>
  
  <pre><code>add_header Last-Modified "Thu, 01 Jan 1970 00:00:00 GMT";
  </code></pre>
  
  <p>b) switching to <code>If-None-Match</code> checks;</p>
  
  <pre><code>add_header ETag $1;
  if_modified_since off;
  </code></pre>
  
  <p>However, the only thing that really worked as needed was this:</p>
  
  <pre><code>add_header Last-Modified "Thu, 01 Jan 2030 00:00:00 GMT";
  if_modified_since before;
  </code></pre>
  
  <p>I'm lost. This is contrary to everything I thought was right. Please help.</p>