31

Why is IIS7.5 only performing static and dynamic compression when the response code is 200?

How do I make it compress all responses where the request had an appropriate Accept-Encoding header?

Thanks

Andrew Bullock
  • 36,616
  • 34
  • 155
  • 231
  • Could it be that the resource you are returning in a non HTTP 200 is not listed in the 'file extensions to compress' list? – Marvin Smit Feb 15 '11 at 11:41
  • nope. just make a blank aspx page, return 200 and it works, return anything else and it doesnt. Well, not 403, 404, 418, or 500 anyway. – Andrew Bullock Feb 15 '11 at 11:43
  • Where are you specifying compressiong? Site level, or machine level? – Taylor Bird Feb 15 '11 at 17:51
  • default is `on` for all sites, at machine level. The site has no overrides, but even if i add it to the web config to force it as on, i get the same behaviour. – Andrew Bullock Feb 15 '11 at 19:12
  • 1
    @Andrew we're wondering the same thing ourselves. – Jarrod Dixon May 07 '11 at 02:15
  • 1
    I reckon it's by design, and the IIS team simply took the wrong decision. – Wim May 07 '11 at 09:46
  • 1
    Don't use IIS's built-in compression anyway. See http://stackoverflow.com/questions/1574168/deflate-compression-browser-compatibility-and-advantages-over-gzip and http://stackoverflow.com/questions/3681516/one-library-for-deflate-gzip-and-zlib-in-net . – David Murdoch May 07 '11 at 17:45

1 Answers1

6

I'm going to answer the 2nd part of your question, How do I make it compress all responses where the request had an appropriate Accept-Encoding header?

You do it with HTTPModules.

Here is one way using Ionic.Zlib. The module prefers to send RAW DEFLATE content because it is ALWAYS faster and ALWAYS smaller than than GZIP (why?).

A more complete solution is now hosted on github https://github.com/davidmurdoch/DEFLATE-Compression-for-IIS .

Community
  • 1
  • 1
David Murdoch
  • 87,823
  • 39
  • 148
  • 191
  • excellent details, thanks for the links to the other questions – Andrew Bullock May 08 '11 at 09:21
  • no problem. the code above was mostly copy/pasted from another source and I never realized how bag the actual code was...so, I'm working on making it better and will update this soon. – David Murdoch May 08 '11 at 17:35
  • yeah no worries, i know how to do it myself (although thanks for the info on the zip lib). just couldnt understand why IIS was being strange, thought i was doing something wrong. seems not, its just poorly designed. – Andrew Bullock May 09 '11 at 09:07
  • @Andrew, I put a little something together on github for this: https://github.com/davidmurdoch/DEFLATE-Compression-for-IIS – David Murdoch May 09 '11 at 23:24