Don't miss out Virtual Happy Hour this Friday (April 26).

Try our conversational search powered by Generative AI!

Marco ter Horst
Feb 9, 2012
  18381
(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
Solving the mystery of high memory usage

Sometimes, my work is easy, the problem could be resolved with one look (when I’m lucky enough to look at where it needs to be looked, just like th...

Quan Mai | Apr 22, 2024 | Syndicated blog

Search & Navigation reporting improvements

From version 16.1.0 there are some updates on the statistics pages: Add pagination to search phrase list Allows choosing a custom date range to get...

Phong | Apr 22, 2024

Optimizely and the never-ending story of the missing globe!

I've worked with Optimizely CMS for 14 years, and there are two things I'm obsessed with: Link validation and the globe that keeps disappearing on...

Tomas Hensrud Gulla | Apr 18, 2024 | Syndicated blog

Visitor Groups Usage Report For Optimizely CMS 12

This add-on offers detailed information on how visitor groups are used and how effective they are within Optimizely CMS. Editors can monitor and...

Adnan Zameer | Apr 18, 2024 | Syndicated blog