tags:

views:

621

answers:

4

Hi,

I'm developing an JSF web app on Tomcat, planning to use Seam in the near future, and I want to add compression of our web pages and resources (i.e. Javascript & CSS files). I'm aware of three methods to GZIP responses in a Java web :

  1. Use Ehcache GZIP filter: it's used in Appfuse, so it's probably solid and it checks if the user agent supports GZIP before applying it, but it seems to have problems with Seam, which we will be using (http://seamframework.org/Community/EHCacheGZipFilterIncompatibleWithSeam)

  2. Use pjl-filter. From the stackoverflow question: "tomcat-compression-does-not-add-a-content-encoding-gzip-in-the-header" (sorry, newbies can't add more than 1 hyperlink per question ), it appears it doesn't have any memory leaks, but I don't know if it has problems with Seam or not.

  3. Use Tomcat's built in compression - although it may not provide a content encoding (Tomcat 6.0.14 seems to work fine, but you can only provide a black list for what user agents compression should not be applied to.

Does anyone have experience with these methods in a JSF-Seam environment? Which is the "best" solution?

Thanks, Glen

A: 

How about adding an nginx front-end and letting it to do the compression (and caching)?

http://wiki.nginx.org/Main

In this case, belongs on serverfalut :)

alamar
A: 

I tried a Servlet filter to add GZIP compression (not Ehcache though) and couldn't get it work properly. I ended up putting Apache with mod_jk in front of the app Server. All it took was a few minutes to configure GIP compressiion and I'm also feeling a lot more secure since just one app is exposed instead of the whole App Server.

Elmar Weber
+1  A: 

Hi, You should try the Jawr API

A: 

An alternative Servlet filter can be found here:

http://onjava.com/pub/a/onjava/2003/11/19/filters.html

Like Ehcache, it tests to see if the browser supports it. I can't say categorically if it plays nicely with Seam, but I've used it in the past without trouble.

Neil McKeown