10
votes

Has anyone got the

<httpCompression minFileSizeForComp="XXX">

setting to be honored by IIS 7.x? The documentation here, http://www.iis.net/ConfigReference/system.webServer/httpCompression#005, states

Optional uint attribute. Specifies the minimum number of kilobytes a file must contain in order to use on-demand compression. The default value for IIS 7.5 is 2700; for IIS 7.0 the default value was 256.

I think the documentation meant bytes and not kilobytes. Could you imagine only HTTP compressing a response when it is 2.7 MB or greater?

I tried setting this value in the ApplicationHost.config and web.config with no affect.

3
The docs are definately wrong in regards to the number of bytes. It is not kilobytes (1000's of bytes), but rather bytes. You can confirm this by looking at the IIS 7.x Compression setting which has the following checkbox text: "Only compress files larger than (in bytes):"evermeire

3 Answers

3
votes

IIS definitely respects the minFileSizeForComp setting. However if both dynamic and static compression is enabled then the small file may be compressed by dynamic compression. I wrote a blog post about it and shared the troubleshooting steps using the Failed Request Tracing rules and provided a solution / workaround for this behavior. Please find it in the following link:

Enlightining a mystery with Failed Request Tracing: does IIS not respect the minFileSizeForComp setting for static compression https://blogs.msdn.microsoft.com/amb/2016/05/23/iis-respects-minfilesizeforcomp-for-static-compression/

Hope that helps someone.

-- AMB

1
votes

I know I'm very late here, but I did some experiments around this issue and have determined that the value is measured in kilobytes. This seems insane, but it's true.

I made a blog post with a little more detail here.

EDIT: Hmm, the issue doesn't seem to be quite this simple. IIS seems to refuse to compress files below a certain size regardless of what is selected.

0
votes

Per @ahmetmithat's answer above, static files that are not compressed because they are smaller than the minFileSizeForComp threshold will be picked up by dynamic compression (if enabled) if their media type (mimeType) is added in both the staticTypes and dynamicTypes. One solution to this is to clear the dynamicTypes inherited from the machine configuration (applicationHost.config) and add just those types that you wish to compress dynamically. For example, if the only dynamic type you will be returning is JSON from your REST APIs, you could configure your web.config as follows:

<httpCompression>
  <dynamicTypes>
    <clear />
    <add mimeType="application/json" enabled="true" />
    <add mimeType="*/*" enabled="false" />
  </dynamicTypes>
</httpCompression>