title: Apache - serving pre-compressed gzip file doesn't work
body: <p>I'm having trouble using the rewrite rules for Apache (2.4) to serve compressed files.</p>
  
  <p>My javascript bundling process generate .gz files for every .js it creates. I've activated the rewrite module on apache <code>a2enmod rewrite</code> and set the <code>.htacess</code> file like this:</p>
  
  <pre><code>AddEncoding gzip .gz
  RewriteEngine on
  
  RewriteCond %{HTTP:Accept-encoding} gzip
  RewriteCond %{REQUEST_FILENAME}\.gz -s
  RewriteRule "^(.*)\.js" "$1\.js\.gz" [QSA]
  
  # Serve correct content types, and prevent mod_deflate double gzip.
  RewriteRule "\.js\.gz$" "-" [T=text/javascript,E=no-gzip:1]
  
  &lt;FilesMatch ".+\.(js\.gz)$"&gt;
    Header append Content-Encoding gzip
    Header append worked yes   
  &lt;/FilesMatch&gt;
  </code></pre>
  
  <p>The problems I'm running are:</p>
  
  <ol>
  <li>The first condition <code>RewriteCond %{HTTP:Accept-encoding} gzip</code> never evaluates to true. On Chrome Developer tools the client is sending this header <code>Accept-Encoding:gzip, deflate, br</code> (I've tried adding gzip, deflate, br to the condition but it doesn't work);</li>
  <li>Even if I take this above condition out I can't see the header <code>Content-Encoding</code> in Chrome dev-tools;</li>
  <li>I don't see <code>Content-length</code> in response headers. But it responds with a <code>Transfer-Encoding:chunked</code> which I find weird;</li>
  </ol>
  
  <p>These are the modules that are enabled on my apache (I think they are enabled by default in my ubuntu dist because I didn't active any of those)</p>
  
  <pre><code>access_compat.load  authz_user.load  filter.load       rewrite.load
  alias.conf          autoindex.conf   headers.load      setenvif.conf
  alias.load          autoindex.load   mime.conf         setenvif.load
  auth_basic.load     deflate.conf     mime.load         status.conf
  authn_core.load     deflate.load     mpm_event.conf    status.load
  authn_file.load     dir.conf         mpm_event.load
  authz_core.load     dir.load         negotiation.conf
  authz_host.load     env.load         negotiation.load
  </code></pre>