Try our conversational search powered by Generative AI!

Marco ter Horst
Feb 9, 2012
  18384
(0 votes)

Configuring GZip with IIS 7.5

Today I had a real struggle when trying to change the GZip settings in our EPiServer environment.

I found Frederik Vig’s excellent blog post ( http://www.frederikvig.com/2011/10/faster-episerver-sites-client-side-performance/ ) but like so many users, I also found that getting these supposedly easy settings to work, proved quite a challenge.

Several online posts mentioned that “it just suddenly started working while troubleshooting”. I wasn’t gonna settle for this, so when I too got it to work, I reversed engineered all steps to find out exactly what was needed to get it to work.
This is what I found:

The Case

Common practice is not to GZip images (e.g. jpg’s). Overall it is said that this type of content is already compressed and the tiny bit of extra compression does not compete with the extra CPU power required for GZipping it.
But is this really true IRL?
For one of our customers I found out that it’s not.
Despite several pleads to their content management team.

So I started the quest to “help” this customer server-side by Gzipping images.

The Tools

Crucial tool on this quest was WebPageTest (http://webpagetest.org).
If you don’t know it yet, shame on you! Crawl out under that rock and start harvesting the power.

Second I used IIS Trace logging.
You can enable it using the following command lines:

%windir%\system32\inetsrv\appcmd configure trace "<appPoolname>/" /enablesite
%windir%\system32\inetsrv\appcmd configure trace "<appPoolname>/" /enable /statusCodes:"200-600"

This will create XML files in the C:\inetpub\logs\FailedReqLogFiles folder.
Just open these XML files, go to “Compact View” and search for “compression”

The Quest
Long story short: %Windir%\system32\inetsrv\config\applicationHost.config is more important that you could ever imagine.
In this case it’s simply impossible to achieve your goals just by editing the web.config file. For me this was the hardest thing to grasp at first. Ofcourse I knew of the existence of the applicationhost.config file, but to me it was just the basis. Any specific application settings are set in the web.config, overruling everything else…. fail.

If you want to edit your Gzip settings, both files are equally important.

Here are the settings that work.

applicationHost.config

            <section name="httpCompression" overrideModeDefault="Allow" />

and

       <httpCompression directory="%SystemDrive%\inetpub\temp\IIS Temporary Compressed Files">
           <scheme name="gzip" dll="%Windir%\system32\inetsrv\gzip.dll" dynamicCompressionLevel="4" />
           <dynamicTypes>
               <add mimeType="text/*" enabled="true" />
               <add mimeType="message/*" enabled="true" />
               <add mimeType="application/x-javascript" enabled="true" />
            <add mimeType="image/jpeg" enabled="true" />
               <add mimeType="*/*" enabled="false" />
           </dynamicTypes>
           <staticTypes>
               <add mimeType="text/*" enabled="true" />
               <add mimeType="message/*" enabled="true" />
            <add mimeType="image/jpeg" enabled="true" />
               <add mimeType="application/x-javascript" enabled="true" />
               <add mimeType="application/atom+xml" enabled="true" />
               <add mimeType="application/xaml+xml" enabled="true" />
               <add mimeType="*/*" enabled="false" />
           </staticTypes>
       </httpCompression>

web.config

<httpCompression>
  <staticTypes>
    <add mimeType="text/*" enabled="true" />
    <add mimeType="message/*" enabled="true" />
    <add mimeType="application/javascript" enabled="true" />
    <add mimeType="application/x-javascript" enabled="true" />
    <add mimeType="image/jpeg" enabled="true" />
    <add mimeType="*/*" enabled="false" />
  </staticTypes>
  <dynamicTypes>
    <add mimeType="text/*" enabled="true" />
    <add mimeType="message/*" enabled="true" />
    <add mimeType="application/javascript" enabled="true" />
    <add mimeType="application/x-javascript" enabled="true" />
    <add mimeType="image/jpeg" enabled="true" />
    <add mimeType="*/*" enabled="false" />
  </dynamicTypes>
  <scheme name="gzip" dll="%Windir%\system32\inetsrv\gzip.dll" dynamicCompressionLevel="4" />
</httpCompression>

Seems kinda double doesn’t it.
Like I said: I reverse engineered all settings. If you want to test yourself, just start commenting settings out. You’ll see that you’ll break it.

One last remark: when I finally got Gzip to work for my jpeg images, the benefit of the extra compression (in KB) was next to nothing.
This was kinda WTF for me.
Before I started on this quest, I tested compression on the existing JPG’s on the website using Yahoo’s Smush.it ( http://www.smushit.com/ysmush.it/ ). it told me that there as a lot to gain. So what went wrong?
I started Googling and found this great blog post by Scott Forsyth ( http://weblogs.asp.net/owscott/archive/2009/02/22/iis-7-compression-good-bad-how-much.aspx ).
Based on this calculations I set dynamicCompressionLevel (IIS Trace logs had already shown me, that the GZipping of the images was done by dynamicCompression) to 4.

End result: The webpage with most images 50% smaller.

Good luck on your quest!

Feb 09, 2012

Comments

Feb 9, 2012 04:16 PM

I guess it depends on how well/much the images are compressed before they are uploaded to EPiServer. Often people saves the images on highest quality, because they want them to look good.

Please login to comment.
Latest blogs
Why C# Developers Should Embrace Node.js

Explore why C# developers should embrace Node.js especially with Optimizely's SaaS CMS on the horizon. Understand the shift towards agile web...

Andy Blyth | May 2, 2024 | Syndicated blog

Is Optimizely CMS PaaS the Preferred Choice?

As always, it depends. With it's comprehensive and proven support for complex business needs across various deployment scenarios, it fits very well...

Andy Blyth | May 2, 2024 | Syndicated blog

Adding market segment for Customized Commerce 14

Since v.14 of commerce, the old solution  for adding market segment to the url is not working anymore due to techinal changes of .NET Core. There i...

Oskar Zetterberg | May 2, 2024

Blazor components in Optimizely CMS admin/edit interface

Lab: Integrating Blazor Components into Various Aspects of Optimizely CMS admin/edit interface

Ove Lartelius | May 2, 2024 | Syndicated blog