title: .NET Core Response Compression Middleware for static files
body: <p>I've enabled response compression middleware for my asp.net core 1 application. I've noticed that after enabling this I now see the view response has content-encoding g-zip so it is working for the html. </p>
  
  <p>However, I'm trying to enable it so that static files that are requested from the wwwroot of the project are sent g-zipped as well. For example a js file referenced in the head of the view or a css file. This isn't working at the moment as I see that the files are being sent without content-encoding of g-zip. Is it possible to do what I want to do, or does the middleware not kick in when requesting assets from wwwroot? Code below in configure services:</p>
  
  <pre><code>services.AddResponseCompression(options =&gt;
  {
    options.Providers.Add&lt;GzipCompressionProvider&gt;();
    options.MimeTypes = ResponseCompressionDefaults.MimeTypes.Concat(new[] { 
    "image/jpeg", "image/png", "application/font-woff2", "image/svg+xml"});
    options.EnableForHttps = true;
  });
  
  services.Configure&lt;GzipCompressionProviderOptions&gt;(options =&gt;
  {
    options.Level = CompressionLevel.Optimal;
  });
  </code></pre>
  
  <p>Code in Configure:</p>
  
  <pre><code>app.UseResponseCompression();
  </code></pre>
  
  <p>I am also using useStaticFiles() - not sure how this might affect what I'm trying to do with compression. </p>