enabling gzip compression with Tomcat and Flex
Today I spent a couple hours setting up gzip compression in Tomcat. I’m using Tomcat for a Flex application. Turing gzip compression on in Tomcat was cake, far easier than IIS! Simply open up sever.xml and add the following to your HTTP or HTTPS connector tag
compression="on"
compressionMinSize="2048"
noCompressionUserAgents="gozilla, traviata"
compressableMimeType="text/html,text/xml"
To get AMF traffic compressed add application/x-amf to the comma delimmed list compressableMimeType attribute. Bamm! Works a treat. Well, until your users use Internet Explorer that is. IE has a slightly different requirement for deflating gzip content, go figure, eh? This affects the Flash Player as IE hands it gzip compressed data, not decompressed. IE needs a no-cache response header it seems. Now, AMF traffic is generated from FDS under Tomcat, so need to tweak a setting there. In /WEB-inf/flex/services-config add
<add-no-cache-headers>false</add-no-cache-headers>
to the properties section of your amf channel-definition. If you got HTTPS running already, you would have done that to the secure-amf section. No we can give a full Bamm!
Note: If using ColdFusion with IIS or Apache, you need add the above change to your services-config.xml too.
