Tuesday, April 1, 2014

IIS Dynamic content compression

Let me start of and say I don't care for blogging too much.  However, like so many others in the world of Tech, its important to give back and help others overcome the same problems you've already wasted hours on yourself, and it is a great way to keep a log of all of one's travails.

To the meat of it:

We have an XHR service (REST services) heavy Javascript / HTML5 app written with many technologies, best known are .NET, BackboneJS, RequireJS.

Quite a while ago I set up dynamic compression on our IIS 7 staging environment server.  It was pointed out not long ago that I had never done so in our production environment, thus our JSON requests were being sent and received without gzip compression.

Of course I went to correct this mistake today and couldn't remember how I had set it up in the first place. I scanned the blogs and modified the web.config and and looked under the "compression" setting for the website in IIS, nothing seems to work.  Then I remembered this was an App config settings, not a website specific settings.

So, here's how I managed it:

1) On your IIS 7 server, open up Internet Information Services Manager.

2) At the root level, Double click on the top-most machine to access the IIS settings for the server.

3) This should bring you to a window looking like this:


4) Click on "Configuration Editor" (shown here in the bottom left, under "Management" section

5) Under the "section" dropdown, select "system.webServer," and then "httpCompression":



6) Ensure your settings look approximately like these:

7) Importantly, expand the section labeled "dynamicTypes", you should ensure your JSON types are included, by adding "application/json" and "application/json; charset=utf-8".

8) Once that's all set, navigate to your website item in IIS, click on the "compression" tab and ensure both static and dynamic compression options are selected.

9) Now recycle the App Pool associated with your website and you should be good to.

Happy gzipping. 

No comments:

Post a Comment