title: dotnet core setting Cache-Control has no effect
body: <p>I have configured the dotnet core middleware to output Cache-Control headers. I am looking to cache all static content, but most particularly several .png files. The <strong>cache header</strong> is <strong>not being output?</strong> I am using dotnet core 1.1.1.</p>
  
  <pre><code>public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
  {
      loggerFactory.AddConsole(this.Configuration.GetSection("Logging"));
      loggerFactory.AddDebug();
      app.UseStaticFiles(new StaticFileOptions
          {
              OnPrepareResponse = _ =&gt;
              {
                  var headers = _.Context.Request.GetTypedHeaders();
                  headers.CacheControl = new CacheControlHeaderValue
                  {
                      MaxAge = TimeSpan.FromHours(12)
                  };
              }
          });
  
      if (env.IsDevelopment())
      {
          app.UseDeveloperExceptionPage();
          app.UseBrowserLink();
      }
      else
      {
          app.UseExceptionHandler("/Home/Error");
      }
  
      app.UseIdentity();
  
      // Add external authentication middleware below. To configure them please see http://go.microsoft.com/fwlink/?LinkID=532715
      app.UseMvc(routes =&gt;
      {
          routes.MapRoute(
              "default",
              "{controller=Site}/{action=Site}/{id?}");
      });
  }
  </code></pre>
  
  <p>The code is being ignored, as evidenced by the below screenshot.</p>
  
  <p><a href="https://i.stack.imgur.com/vqXoz.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/vqXoz.png" alt="enter image description here"></a></p>
  
  <p>I have also tried explicitly adding the header like this, but I get errors indicating the header is already present.</p>
  
  <pre><code>app.UseStaticFiles(new StaticFileOptions
  {
      OnPrepareResponse = _ =&gt;
      {
          _.Context.Request.Headers.Add("Cache-Control", "public,max-age=60");
      }
  });
  </code></pre>
  
  <p>Somehow it's getting eaten up. If I set a breakpoint, the code is being called. </p>