November Happy Hour will be moved to Thursday December 5th.

Marco ter Horst
Feb 9, 2012
  18554
(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
Optimizely SaaS CMS + Coveo Search Page

Short on time but need a listing feature with filters, pagination, and sorting? Create a fully functional Coveo-powered search page driven by data...

Damian Smutek | Nov 21, 2024 | Syndicated blog

Optimizely SaaS CMS DAM Picker (Interim)

Simplify your Optimizely SaaS CMS workflow with the Interim DAM Picker Chrome extension. Seamlessly integrate your DAM system, streamlining asset...

Andy Blyth | Nov 21, 2024 | Syndicated blog

Optimizely CMS Roadmap

Explore Optimizely CMS's latest roadmap, packed with developer-focused updates. From SaaS speed to Visual Builder enhancements, developer tooling...

Andy Blyth | Nov 21, 2024 | Syndicated blog

Set Default Culture in Optimizely CMS 12

Take control over culture-specific operations like date and time formatting.

Tomas Hensrud Gulla | Nov 15, 2024 | Syndicated blog