Compartilhar via


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

Comments

  • Anonymous
    December 17, 2013
    This issue is now addressed by an official patch to IIS. To download and further info, visit support.microsoft.com/.../2877816Erez Benari, IIS PM
  • Anonymous
    February 15, 2014
    Erez,I think the fix does not work as expected. If a Vary header value is added, the content returned is not compressed, while if the header is not added, the result is gzipped as expected.I though the patch would allow me to add the header and keeping the compression.Have you tried this scenario ?
  • Anonymous
    February 18, 2014
    Hi Martincad,Could you please share the OS information and repro steps?
  • Anonymous
    September 15, 2014
    Needing this fix too, I have tested it, on win7SP1 (dev workstation) and 2008R2SP1 (IIS server for our continuous integration environment) : works as expected.If a varyByHeader is specified on our asp.net outputCache directive, it is preserved (included in vary response header, completed by Accept-Encoding since compression is enabled). And response is compressed (gzip).So personally I do not reproduce the trouble stated by Martincad.