title: How can I control the HTTP response headers added to my ASP.NET core web application when hosted in Azure app service?
body: <p>we have written an ASP.NET core 2.2 web application which basically exposes a few web api controllers and we have used the <a href="https://docs.microsoft.com/it-it/aspnet/core/performance/caching/middleware?view=aspnetcore-2.2" rel="nofollow noreferrer">ResponseCachingMiddleware</a> in order to implement a server side response cache in our middleware pipeline. </p>
  
  <p>We followed <a href="https://docs.microsoft.com/it-it/aspnet/core/performance/caching/middleware?view=aspnetcore-2.2" rel="nofollow noreferrer">this Microsoft guide</a> and we decided to add the HTTP response header Vary so that each response from our application includes the following header: <code>Vary: Accept-Encoding, Accept-Charset</code>. </p>
  
  <p>Doing so, as explained in the guide linked above, is needed in order for the response cache to honor the client request headers so that the cached responses are used if and only if they are compatible with the client request.</p>
  
  <p>Testing with postman I noticed that, when deploying the app in Azure (we used a standard Azure App Service to do so), the Vary response header is not what I would expect: it seems that Azure itself adds the value <code>Accept-Encoding</code> so that the value for the Vary header is set as <code>Accept-Encoding, Accept-Charset,Accept-Encoding</code> (this is a combination of the value set by our application and the value that, I suppose, is automatically added by Azure).</p>
  
  <p>That said I have a couple of questions: </p>
  
  <ul>
  <li>is the extra value <code>Accept-Encoding</code> really added by the azure host ? </li>
  <li>is there a way to customize the HTTP headers added by the Azure host (if any) ?</li>
  <li>is the value <code>Accept-Encoding, Accept-Charset,Accept-Encoding</code> a valid value for the <code>Vary</code> header ? is it going to work as expected even if we have a value repeated twice ?</li>
  </ul>