6

I have an jsf application (mojarra 2.1.8, primefaces 3.3) running on tomcat 6. While analyzing the page in firebug with google page-speed, I realized I could optimize some stuff by gzip-compression.

Compressing the following resources with gzip could reduce their transfer size by 371,1KiB (74% reduction).

 Compressing http://localhost:8080/someApp/javax.faces.resource/jquery/jquery.js.jsf?ln=primefaces could save 72,5KiB (74% reduction).
 Compressing http://localhost:8080/someApp/javax.faces.resource/theme.css.jsf?ln=primefaces-aristo could save 53,4KiB (71% reduction).
 Compressing http://localhost:8080/someApp/javax.faces.resource/jsf.js.jsf?ln=javax.faces could save 49,6KiB (78% reduction). 
 ...

I already turned on compression in my server.xml

<Connector connectionTimeout="20000" port="8080" protocol="HTTP/1.1" redirectPort="8443"
      compression="on" 
      noCompressionUserAgents="gozilla, traviata"
      compressableMimeType="text/html,text/xml,text/plain,application/javascript,application/json,text/javascript"/>

But it doesn't compress the mentioned files listed above.

What else do I have to do to get compression working?

Jonny

user871611
  • 3,307
  • 7
  • 51
  • 73
  • What are the MIME types of your .js.jsf and .css.jsf resources? What client are you using for testing? – Christopher Schultz Jun 05 '12 at 15:03
  • Hi Christoper,thanks for your response. These resources are provided/added by Primefaces on the fly. .js.jsf has application/javascript (listed in compressableMimeType) and .css.jsf has text/css (ok, isn't listed in compressableMimeType). My client: Latest Chrome Browser on WinXP. Jonny – user871611 Jun 05 '12 at 17:48
  • Do you get the right Content-Type header in the response when requesting those resources from the server? Do you also get a Content-Length header? – Christopher Schultz Jun 06 '12 at 00:58
  • Hi Christopher, thanks for trying to help me out. I get the right content-type and content-lenght. Jonny – user871611 Jun 06 '12 at 06:52

1 Answers1

7

Your server.xml is all fine. Your concrete problem is most likely that you've edited the wrong server.xml file. In an IDE like Eclipse, the original Tomcat server installation is by default kept untouched. Instead, Eclipse creates a copy of all its configuration files in the Servers project and uses the workspace metadata to deploy the webapps and ultimately only the Tomcat server engine is been used from the Tomcat installation.

Make sure that you're editing the right server.xml file, the one in Servers project:

enter image description here

Tomcat's own /conf/server.xml file is only used when you start it outside Eclipse, or when you tell Eclipse to take full control over Tomcat installation instead. To do that, doubleclick the Tomcat server entry in Servers view and alter the Server Locations accordingly.

enter image description here

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
  • Hi BalusC, thanks for detailed information. I was editing the right server.xml in my Servers project. The text/html is gziped, but not the css and js stuff. Drives me crazy :). Jonny – user871611 Jun 06 '12 at 06:49
  • 1
    You don't have a `text/css` in your `compressableMimeType` list. Are you sure that you're looking at the right response? Responses on cache verification requests like 304 "Not Modified" responses are of course NOT gzipped. – BalusC Jun 06 '12 at 12:13
  • Hi BalusC, I already added the text/css-compressableMimeType. But you answerded my problem in the second part of your comment. I emptied my cache and now it 'works'. Thanks a million BalusC – user871611 Jun 06 '12 at 12:45
  • You're welcome. You could instead also just have done a Ctrl+F5 or Ctrl+R to force a hard refresh, depending on browser make. – BalusC Jun 06 '12 at 12:54