Thursday, March 29, 2012

How to Enable Gzip HTTP Compression in JBoss AS 7.1.1

JBoss AS 7.1.1 has finally returned the powerful Gzip HTTP Compression support (AS7-2991) that was missing since 7.0.0.

Edit standalone/configuration/standalone.xml and add <system-properties> after the </extensions> :

... <extension module=""/> </extensions> <system-properties> <property name="org.apache.coyote.http11.Http11Protocol.COMPRESSION" value="on"/> </system-properties>

Proof :

$ curl --head --compressed http://localhost:9080/
HTTP/1.1 200 OK
Server: Apache-Coyote/1.1
Accept-Ranges: bytes
ETag: W/"2432-1331360042000"
Last-Modified: Sat, 10 Mar 2012 06:14:02 GMT
Content-Type: text/html
Transfer-Encoding: chunked
Content-Encoding: gzip
Vary: Accept-Encoding
Date: Fri, 30 Mar 2012 00:40:36 GMT

If you're running your app on OpenShift, it doesn't hurt to enable this switch now. That way, when OpenShift upgrades to JBoss AS 7.1.1 or later, your app will get HTTP Compression automatically. :-)

Alternative: You can also enable it by adding to the server launch params :


Enables HTTP compression on JBoss 7.1.1

To learn more about Java Web Development using Java EE 6, I highly recommend The Java EE 6 Tutorial: Basic Concepts (4th Edition) (Java Series) by Eric Jendrock, Ian Evans, Devika Gollapudi and Kim Haase.