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?
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.