The Source for Java Technology Collaboration
User: Password:



Jean-Francois Arcand

Jean-Francois Arcand's Blog

Enabling HTTP Compression in GlassFish

Posted by jfarcand on June 07, 2006 at 11:33 AM | Comments (4)

Glassfish b06 now support HTTP Compression, the same way Tomcat is supporting it. Several options are availaible (from Tomcat docs):

compressableMimeType: The value is a comma separated list of MIME types for which HTTP compression may be used. The default value is text/html,text/xml,text/plain.

compression: The Connector may use HTTP/1.1 GZIP compression in an attempt to save server bandwidth. The acceptable values for the parameter is "off" (disable compression), "on" (allow compression, which causes text data to be compressed), "force" (forces compression in all cases), or a numerical integer value (which is equivalent to "on", but specifies the minimum amount of data before the output is compressed). If the content-length is not known and compression is set to "on" or more aggressive, the output will also be compressed. If not specified, this attribute is set to "off".

noCompressionUserAgents: The value is a comma separated list of regular expressions matching user-agents of HTTP clients for which compression should not be used, because these clients, although they do advertise support for the feature, have a broken implementation. The default value is an empty String (regexp matching disabled).

minCompressionSize: The minimum size of a file when compression is applied.

You can enable HTTP compression using two approaches:

The fastest way is to edit ${glassfish.home}/domains/domain/config/domain.xml, and add, under the http-listener element:

    <http-listener>
        <property name="compression" value="on"/>
        <property name="compressableMimeType" value="...."/>
    </http-listener>

Or you can using do it using GlassFish admin CLI:

% asadmin set server.http-service.http-listener.http-listener-1.
property.compression=force

Once Issue 607 is fixed, you gonna be able to use the Admin Gui to configure HTTP compression as well. technorati:

Bookmark blog post: del.icio.us del.icio.us Digg Digg DZone DZone Furl Furl Reddit Reddit
Comments
Comments are listed in date ascending order (oldest first) | Post Comment

  • I am using Sun App Server 9 Update 1. I tried configuring the compression by modifying the domain.xml file. The result was "Unsupported http-listener property (compression) is being ignored." When I used the asadmin command it basically echoed out the property. However, when I request a jsf page, I see the same amount of network traffic... i.e.... the compression seemed to have zero effect.

    Posted by: dandaley on December 13, 2006 at 01:00 PM

  • Hi, this is only available in 9.1 unfortunately. Can you try 9.1? Thanks! -- Jeanfrancois

    Posted by: jfarcand on December 14, 2006 at 07:42 AM

  • Works like a gem! I'd been trying to setup compression with SJSAS 8.2EE behind Apache 2 (Apache 2 doing the compression), but it had problems doing page reloads with SSL streams. No such problem exists in GF. Looking forward to an official SJSAS EE port of Glassfish sometime soon so we can start using this in production.

    Posted by: coreyjohnston on December 18, 2006 at 02:38 PM



Only logged in users may post comments. Login Here.


Powered by
Movable Type 3.01D
 Feed java.net RSS Feeds