X

Technology insights, news and tips.

  • Sun
    September 26, 2008

compression and compressionMinSize in GlassFish v3

In Enabling HTTP Compression in GlassFish,
Jean-Francois discussed about compression in
GlassFish.
There are four properties to configure compression, namely:
  • compression
  • compressionMinSize (in OCTET)
  • compressableMimeType
  • noCompressionUserAgents

One can turn compression
on and off by setting compression = force and
compression = off respectively.
And one can also turn on the compression
if the content-length is unknown or known to be greater than a certain size.
There are two properties related to this: compression and compressionMinSize.
In this blog, we will discuss various ways to accomplish this scenario
in GlassFish v3.

compression vs compressionMinSize


propertypossible value if setDefault
compressionon, force, off, integeroff
compressionMinSizeinteger2048

There are several possible combinations. We will summarize the behaviors
of GlassFish v3 in the below table.
In the following, α and β are integers.


compressioncompressionMinSizeResult
onβcompression with min size β
onnot setcompression with default min size (2048)
forceβ or not setcompression with no size constraint
αβ or not setcompression with min size α
off or not setβ or not setno compression

So, roughly speaking, whenever there is conflicting
information between compression and compressionMinSize, the
compression property will take precedence.

Since we use strict inequality to check for known
content length, the following are equivalent:

  • compression = force
  • compression = on and compressionMinSize = any negative integer

How to test it?


If one has turned on compression in GlassFish, then one will get HTTP
compression if the HTTP request is
  • using HTTP 1.1
  • with a HTTP header:
        Accept-Encoding: gzip
  • the content-length is unknown or greater than the compression minimum size
    (or compression = force)

One can confirm that there is a HTTP compression by using Firefox with Firebug.
There will be a HTTP response header:
  • Content-Encoding: gzip

Note that one can also notice some changes in HTTP response
for HTTP compression by using the http client posted in one of my previous
blogs.

Join the discussion

Comments ( 2 )
  • Balte Monday, September 29, 2008

    Will it support gzip stream from client, too?


  • Russ Monday, December 15, 2008

    Regarding the "OCTET": "compressionMinSize (in OCTET)", are you saying it must be a multiple of 1024? If so, what does it do if the number entered is say, "5000"? Thanks.


Please enter your name.Please provide a valid email address.Please enter a comment.CAPTCHA challenge response provided was incorrect. Please try again.