London Dev Meetup Rescheduled! Due to unavoidable reasons, the event has been moved to 21st May. Speakers remain the same—any changes will be communicated. Seats are limited—register here to secure your spot!


Feb 9, 2012
  18762
(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
Notes on Optimizely Self-Optimizing Block

While the free A/B Testing might be dead , the Self-Optimizing Block is still alive and kicking. Here's some notes for those debugging it.  ...

Jacob Pretorius | Apr 29, 2025

Optimizely Product Recommendation Troubleshooting

In today’s fast-paced digital landscape, personalization is everything . Customers expect relevant, tailored experiences whenever they interact wit...

Sanjay Kumar | Apr 28, 2025

Natural Language Q&A in Optimizely CMS Using Azure OpenAI and AI Search

In Part 2, we integrated Azure AI Search with Azure Personalizer to build a smarter, user-focused experience in Optimizely CMS. We used ServiceAPI ...

Naveed Ul-Haq | Apr 25, 2025 |

Identifying Spike Requests and Issues in Application Insights

Sometimes within the DXP we see specific Azure App Instances having request spikes causing performance degredation and we need to investigate. I fi...

Scott Reed | Apr 25, 2025