2

IIS compression has been enabled: enter image description here

The following is the httpCompression tag of web.config:

<httpCompression
      directory="%SystemDrive%\inetpub\temp\IIS Temporary Compressed Files"
      minFileSizeForComp="1"
      staticCompressionIgnoreHitFrequency="true"
      dynamicCompressionIgnoreHitFrequency="true">
  <dynamicTypes>
    <add mimeType="*/*" enabled="true" />
  </dynamicTypes>
  <staticTypes>
    <add mimeType="*/*" enabled="true" />
  </staticTypes>
</httpCompression>  

I see only CSS and JavaScript files are compressed when running the web app: enter image description here enter image description here

Unfortunately, other files are not compressed:

enter image description here

I do not seee "IIS Temporary Compressed Files" in "C:\inetpub\temp".

Could anyone provide a tip on how to diagnose this?

Update[2020-08-13] Configuration Editor on Windows Server 2016:

enter image description here

Update[2020-08-13] Per @Kul-Tigin, Dynamic Content Compression needs to be installed: enter image description here

Hong
  • 17,643
  • 21
  • 81
  • 142
  • 1) IIS Manager exposes too few settings, so you must study the configuration file, https://learn.microsoft.com/en-us/iis/configuration/system.webserver/httpcompression/ 2) To troubleshoot, https://learn.microsoft.com/en-us/iis/troubleshoot/performance-issues/troubleshooting-iis-compression-issues-in-iis6-iis7x – Lex Li Jul 25 '20 at 15:07
  • I did a lot reading before posting the question. I wonder if all the information for IIS 6 and 7 is still relevant. – Hong Jul 25 '20 at 16:38
  • If you did read a lot, you know IIS 7 and above are the same. – Lex Li Jul 25 '20 at 17:21

1 Answers1

3
  1. There's no such a setting named dynamicCompressionIgnoreHitFrequency, remove it.

  2. 1 (in bytes) for minFileSizeForComp is a little bit harsh. Compressing small files just decreases the response size. Leave it 2700 as default.

  3. Unlike setting values on attributes (like you did in staticCompressionIgnoreHitFrequency="true"), adding a setting as node won't override inherited ones.

    Before adding, removing possibly inherited corresponding setting or clear all the inherited ones is a good practice to prevent errors (especially silent ones).

    Otherwise an error may occur or worse a silent error may break your setting.

  4. 100 (in MB) for per application pools space limit may be insufficient for your needs. If I recall correctly most of your files are WebAssembly files of megabytes.

    Since you want all files to be compressed if possible; specify a value big enough.

    Big as if possible; the sum of the uncompressed lengths of all your files. Say 2048 MB.

    With this way you can't reach the disk space limit so none of your compressed caches are not deleted due to lack of space.

    As long as the original file has not changed, the compressed caches survive and be delivered.

    I have 3 years old compressed cache files stored on my servers, ready to be delivered BTW.

So, give the following a try.

If it does not work, please provide more information about request headers and the files that are delivered as uncompressed.

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.webServer>
        <httpCompression 
        sendCacheHeaders="false" 
        directory="%SystemDrive%\inetpub\temp\IIS Temporary Compressed Files" 
        doDiskSpaceLimiting="true" 
        maxDiskSpaceUsage="2048" 
        minFileSizeForComp="2700" 
        noCompressionForHttp10="true" 
        noCompressionForProxies="true" 
        noCompressionForRange="true" 
        staticCompressionIgnoreHitFrequency="true" 
        staticCompressionDisableCpuUsage="100" 
        staticCompressionEnableCpuUsage="50" 
        dynamicCompressionDisableCpuUsage="90" 
        dynamicCompressionEnableCpuUsage="50" 
        dynamicCompressionBufferLimit="65536">
          <dynamicTypes>
            <clear />
            <add mimeType="*/*" enabled="true" />
          </dynamicTypes>
          <staticTypes>
            <clear />
            <add mimeType="*/*" enabled="true" />
          </staticTypes>
        </httpCompression>  
    </system.webServer>
</configuration>
Kul-Tigin
  • 16,728
  • 1
  • 35
  • 64
  • 1
    Thank you very much. This works like a charm instantly. I regret spending so much time on this trying all kinds of things to no avail. I found under is the key. Nothing would be compressed without it. I have done a lot of reading, but do not remember anyone mentioning this. Everyone trying IIS compression should know this! I will boldface this part of your answer assuming you do not mind. – Hong Jul 27 '20 at 01:51
  • 1
    @Hong Yeah, documentations mostly fail to address edge cases like this, so we learn by suffering. I'm glad I could help. – Kul-Tigin Jul 27 '20 at 02:02
  • It is weird that the configuration works perfectly on Windows 10 Pro, but not on Windows server 2016. I just copied web.config from the Windows 10 PC to the Windows Server 2016. There is no compression by the latter. Could you offer a tip on this? – Hong Aug 13 '20 at 15:43
  • 1
    @Hong The configurations of your developer machine and the server may differ. If you don't have any errors, as shown [here](https://stackoverflow.com/a/59044022/893670), by using IIS Manager on Windows Server 2016, make sure that the section `system.webServer/httpCompression` is unlocked and allows overriding. If that doesn't help, try to use failed request tracing module to troubleshoot. – Kul-Tigin Aug 13 '20 at 20:27
  • Thank you. I actually tried to use Configuration Editor to enable compression out of desperation. Since I cannot add an image here, I edited my question by adding a screenshot of the Configuration Editor. I will try failed request tracing. – Hong Aug 13 '20 at 21:29
  • 1
    @Hong In the first row of the grid, the value of collection count should have been 2 not 1 `(Count=1)`. Are you sure you have installed the IIS Brotli module on the server? – Kul-Tigin Aug 13 '20 at 22:23
  • 1
    Thanks a lot. It is working now after installing Dynamic Content Compression according to your tip (see the new screenshot of my updated question). I do not see the folder IIS Temporary Compressed Files. I deleted it two weeks ago because I thought IIS would create it automatically. I am worried that IIS is not using cache. – Hong Aug 13 '20 at 23:44