title: Cache Control on wwwroot subfolders Net core 2.2
body: <p>I'm trying to add cache control headers to .js and .css files which live in wwwroot/dist. If I output my files directly into wwwroot rather than wwwroot/dist (from webpack) the headers are added without issue via the below code:</p>
  
  <pre><code>            app.UseStaticFiles(new StaticFileOptions
              {
                  OnPrepareResponse = ctx =&gt;
                  {
                      const int durationInSeconds = 60 * 60 * 24 * 365;
                      ctx.Context.Response.Headers[HeaderNames.CacheControl] =
                          "public,max-age=" + durationInSeconds;
                  }
          });
  </code></pre>
  
  <p>however this method seems to ignore sub folders.
  Due to this I have added the following code directly below the code seen above:</p>
  
  <pre><code>         app.UseStaticFiles(new StaticFileOptions
          {
              FileProvider = new PhysicalFileProvider(
                  Path.Combine(Directory.GetCurrentDirectory(), "wwwroot", "dist")),
              RequestPath = "/dist",
              OnPrepareResponse = ctx =&gt;
              {
                  const int durationInSeconds = 60 * 60 * 24 * 365;
  
                      ctx.Context.Response.Headers[HeaderNames.CacheControl] =
                          "public,max-age=" + durationInSeconds;  
              }
          });
  </code></pre>
  
  <p>The files do ideally need to be contained in the 'dist' folder as this is ignored in source control and the output files contain a hash so I can't feasibly manually add them to my git ignore.</p>
  
  <p>Further to this it seems like any files served from a sub folder of wwwroot always have no-cache set in the request headers. </p>
  
  <p>Any advice on this issue would be greatly appreciated.</p>