How to best handle dynamic and static compression?

Jared Gotte asked on May 11, 2017 20:03

So the best output compression combination I've found so far (for IIS 7 & 8) is to:

  1. Enable dynamic compression via IIS to handle all desired compression algorithms (gzip, deflate, br, etc.)
    • Fine-tune both the dynamic and static compression settings via the applicationHost.config file (see the httpCompression excerpt below)
  2. Enable both output compression for pages and resources via Kentico's Settings
  3. Define the desired encoding priority order in our custom web applications, e.g. deflate > gzip (explained here)

This way:

  1. We dynamically compress resources that Kentico cannot (custom handlers, System level handlers like WebResource.axd, etc.)
  2. We provide fallback compression algorithms for browsers that do not support deflate
  3. We override the outdated safe static compression default settings that IIS provides at install
  4. For our custom output, we can override the questionable way IIS 7+ prioritizes which encoding to use (left-to-right in the Request Header, given no qvalues, which I can't find specified in any RFC version – e.g. see this section in 7231)

Has anyone found a better combination?

Here are the httpCompression settings I'm using in my applicationHost.config file:

<httpCompression directory="%SystemDrive%\inetpub\temp\IIS Temporary Compressed Files" minFileSizeForComp="1024" staticCompressionIgnoreHitFrequency="true">
    <scheme name="gzip" dll="%Windir%\system32\inetsrv\gzip.dll" staticCompressionLevel="9" dynamicCompressionLevel="4" />
    <scheme name="deflate" dll="%Windir%\system32\inetsrv\gzip.dll" staticCompressionLevel="9" dynamicCompressionLevel="4" />
    <dynamicTypes>
        <clear />
        <add enabled="true" mimeType="text/*" />
        <add enabled="true" mimeType="message/*" />
        <add enabled="true" mimeType="application/javascript*" />
        <add enabled="true" mimeType="application/json*" />
        <add enabled="true" mimeType="application/x-javascript*" />
        <add enabled="false" mimeType="*/*" />
    </dynamicTypes>
    <staticTypes>
        <clear />
        <add enabled="true" mimeType="text/*" />
        <add enabled="true" mimeType="message/*" />
        <add enabled="true" mimeType="application/javascript*" />
        <add enabled="true" mimeType="application/json*" />
        <add enabled="true" mimeType="*/*+xml*" />
        <add enabled="true" mimeType="application/vnd.ms-fontobject*" />
        <add enabled="true" mimeType="font/otf*" />
        <add enabled="true" mimeType="application/octet-stream*" />
        <add enabled="false" mimeType="*/*" />
    </staticTypes>
</httpCompression>

Any feedback is appreciated!

   Please, sign in to be able to submit a new answer.