我正在尝试通过web.config禁用“via”头,我尝试了以下操作,但没有成功:
设置#1
<system.webServer>
<httpProtocol>
<customHeaders>
<remove name="Vary" />
</customHeaders>
</httpProtocol>
</system.webServer>设置#2
<rewrite>
<outboundRules rewriteBeforeCache="true">
<rule name="Remove Vary Header">
<match serverVariable="RESPONSE_Vary" pattern=".+" />
<action type="Rewrite" value="" />
</rule>
</outboundRules>
</rewrite>这两种设置都不起作用,我很好奇我做错了什么?
发布于 2020-04-07 04:31:54
我找到了这个问题的答案。如果启用了压缩,IIS将覆盖"Vary“标头,因此在web.config中实现以下内容将防止IIS覆盖您的重写规则:
<system.webServer>
<urlCompression doStaticCompression="false" doDynamicCompression="false"/>
</system.webServer>您将遇到的唯一问题是,如果压缩已在web.config中使用,则尝试禁用压缩。如果开发人员正在使用压缩,您将需要与他们合作,以删除它。
https://stackoverflow.com/questions/60956107
复制相似问题