IIS compression overwrites the VARY: header

Symptoms

IIS compression overwrites the VARY header. If for example an ASP.NET Web Service adds the HTTP header "Vary: Accept-Language, Accept-Encoding” to every response, it may work fine until IIS compression is enabled.  The vary header may still contain: “Vary: Accept-Encoding” but it no longer in this example contains the "Vary: Accept-Language, Accept-Encoding” that the web service had added.

Cause

This is by design. 

Resolution

As of Dec 17 2013, this issue is now addressed by an official patch to IIS.

To download and further info, visit https://support.microsoft.com/kb/2877816

     - Erez Benari, IIS PM

 

 

 

Workaround

The IIS compression code is overwritting the header after SF_NOTIFY_SEND_RESPONSE.   The only way around that would be to use an ISAPI filter.   But the filter would have to rewrite the header after SF_NOTIFY_SEND_RESPONSE.  It may be possible to have a filter rewrite the header in SF_NOTIFY_SEND_RAW_DATA.  But this has not been tested out yet to know for sure.

Products Affected

Internet Information Services (IIS) 5.0, 6.0 and IIS 7.0.   

  

More Information

If you use the ISAPI, then IIS6 would need to be run in IIS 5.0 isolation mode. 
https://support.microsoft.com/kb/311852
Information about ISAPI filters that register the SF_NOTIFY_READ_RAW_DATA event in Internet Information Services version 6.0

Also, if you use the ISAPI filter, you can expect a significant performance hit.
https://blogs.msdn.com/david.wang/archive/2005/12/14/How-IIS6-Compression-Schemes-interact-with-ISAPI-Filters.aspx
“SF_NOTIFY_SEND_RAW_DATA is an absolute/performance optimization killer.”