Wednesday, December 22, 2010

Enabling HTTP compression of web-services on Microsoft Forefront TMG 2010


How to find whether the compression is enabled?
Use Firebug (or similar tools) to inspect the HTTP request – it should contain the header:
Accept-Encoding: gzip,deflace
Then inspect the HTTP response, it should contain the header
Content-Encoding: gzip

Enabling compression on the IIS level
The content is served probably by an IIS web server, therefore you have to enable the compression there. There are two wals described in the following article:

Practical tip
Before you start digging into the Forefront setting, test the HTTP compression locally by bypassing any servers that may change the HTTP conversation. Your web site/service probably listens also on some local address such as http://localhost:12345 or http://server-name/web-site-name, etc. Use the procedure from previous paragraph to test, whether the IIS compresses the content.

Note
You do not have to compress the content by the IIS and let only the Forefront server to do that. This depends on your decision about the network topology and the way you access the web-site (Are there any clients accessing the web site directly? Do they need the HTTP compression?)
Enabling compression on the Forefront TMG (similar for Microsoft ISA Servers)
Now you have to configure the Forefront TMG server to use the compression for your web site (and for the web service responses). Follow the following article:

The compression is applied selectively, based on particular content-types transmitted through the Forefront server. By default, only HTML and text documents are served (this is quite smart as it makes no sense to compress some content – such as images, ZIP files, etc. – twice). Unfortunately the web service response is server as a XML content (having text/xml mime-type). To compress this type of content, you should add new content-type (using the following article):

And then you have to enable the compression for this content type (previous link http://technet.microsoft.com/en-us/library/cc995193.aspx)

Practical tip
Unless you are really sure by the routing of request between different Forefront named-objects, try adding more general objects (such as Anywhere) in the tabs of objects on which the Forefront server applies the compression. Once your compression will be up and running, you can again narrow the definition of compressed objects.