1

I'm trying to disable the "Vary" header via web.config and I've tried the following with no success:

Setting #1

<system.webServer>
  <httpProtocol>
   <customHeaders>
    <remove name="Vary" />
   </customHeaders>
  </httpProtocol>
</system.webServer>

Setting #2

<rewrite>
 <outboundRules rewriteBeforeCache="true">
  <rule name="Remove Vary Header">
   <match serverVariable="RESPONSE_Vary" pattern=".+" />
   <action type="Rewrite" value="" />
  </rule>
 </outboundRules>
</rewrite>

Neither setting works, I'm curious as to what I am doing wrong?

Ostrava
  • 95
  • 1
  • 9
  • I am unfamiliar with the problem, but [Unable to append 'Vary' header to response](https://stackoverflow.com/questions/7849392/unable-to-append-vary-header-to-response) looks like at least one of the answers might be relevant, even for IIS 10. – Andrew Morton Mar 31 '20 at 17:17
  • Hey Andrew, I followed the answers provided within the link you had sent to me and all it does is append to Vary: Accept-Encoding – Ostrava Mar 31 '20 at 18:06
  • I hoped that, lacking an example of a Vary header that you wanted to remove, something in there would have been relevant. Oh well, at least the next person to come along will know what not to suggest :) – Andrew Morton Mar 31 '20 at 18:11
  • you could try to change the value if the very header by using this rule: ` ` – Jalpa Panchal Apr 01 '20 at 08:56

1 Answers1

0

I figured out the answer to this question. IIS overwrites the "Vary" header if compression is enabled, so implementing the following into your web.config will prevent IIS from overwriting your rewrite rules:

<system.webServer>
  <urlCompression doStaticCompression="false" doDynamicCompression="false"/>
</system.webServer>

The only problem that you will run into will be trying to disable compression if it is already being used in the web.config. If devs are using compression, you will need to work with them to remove it.

Ostrava
  • 95
  • 1
  • 9