1 2 Previous Next 20 Replies Latest reply on Mar 6, 2013 11:07 AM by maslov_eugine

    GZip compression for connector in JBoss 7.0.x

    cmay4

      We are converting a project from 4.2.3 to 7 (currently 7.0.1).  Everything is working except that we can find no reference on how to turn on gzip compression in the connector.  This is how we did it in 4.2.3:

       

          <Connector port="443" address="${jboss.bind.address}" protocol="HTTP/1.1" SSLEnabled="true"

                   maxThreads="150" scheme="https" secure="true"

                   clientAuth="false" sslProtocol="TLS"

                   emptySessionPath="true" compression="on"

                   compressableMimeType="text/html,text/xml,text/plain,text/css,text/javascript"

                   keystoreFile="${jboss.server.home.dir}/conf/keystore" keystorePass="*****"/>

       

      and this is what we have so far in 7:

       

         <subsystem xmlns="urn:jboss:domain:web:1.0" default-virtual-server="default-host">

            <connector name="https" protocol="HTTP/1.1" socket-binding="https" scheme="https"

                    enable-lookups="false" secure="true">

               <ssl name="ssl" password="seerdms" certificate-key-file="../bin/keystore" protocol="TLSv1"/>

            </connector>

            <virtual-server name="default-host" enable-welcome-root="true">

               <alias name="localhost"/>

               <access-log />

            </virtual-server>

         </subsystem>

       

      I've looked through jboss-as-web_1_0.xsd and seen no reference to the "compression" attribute.  Is there another way to accomplish this?  Seems like I must be missing something but searching the documentation and online has returned nothing so far.

       

      Thanks for any help,

       

      Chuck

        • 1. Re: GZip compression for connector in JBoss 7.0.x
          cmay4

          After more searching, it just seems like the built in compression options were removed in AS7 with no mention in any changelog that I could find.  Specifically it should have shown up in the migration document:

           

          https://docs.jboss.org/author/display/AS7/How%2Bdo%2BI%2Bmigrate%2Bmy%2Bapplication%2Bfrom%2BAS5%2Bor%2BAS6%2Bto%2BAS7

           

          In the end, we just had to add a compression filter to web.xml.  We ended up using the one at:

           

          https://code.google.com/p/webutilities/wiki/CompressionFilter

           

          Pretty straightforward.

          • 2. Re: GZip compression for connector in JBoss 7.0.x
            hfluz

            No news about gzip compression in JBoss AS 7?

            • 3. Re: GZip compression for connector in JBoss 7.0.x
              hfluz

              I created a feature request for the issue: https://issues.jboss.org/browse/AS7-2991

              • 4. Re: GZip compression for connector in JBoss 7.0.x
                varkon

                According to that issue (that seems to be fixed in version 7.1.1.Final), compression is now enabled. However, I cannot find any trace of documentation on how to enable it.

                Does anybody have any information on that?

                 

                Thanks.

                • 5. Re: GZip compression for connector in JBoss 7.0.x
                  hfluz

                  I thought that could be like this:

                   

                  <server name="xyz.home" xmlns="urn:jboss:domain:1.0">
                      <extensions>
                          <extension module="org.jboss.as.clustering.infinispan"/>
                          <extension module="org.jboss.as.clustering.jgroups"/>
                          <extension module="org.jboss.as.connector"/> 
                          ....
                          <extension module="org.torquebox.web"/>
                      </extensions>
                      <system-properties>
                          <property name="org.apache.coyote.http11.Http11Protocol.COMPRESSION" value="true"/>
                  </system-properties>

                   

                  But that didn't worked out for me.

                  • 6. Re: GZip compression for connector in JBoss 7.0.x
                    varkon

                    I know, I tried that, as well as passing it as a parameter during startup (which should be the same thing).

                    • 7. Re: GZip compression for connector in JBoss 7.0.x
                      ceefour

                      Doing this is not working :

                       

                      <subsystem xmlns="urn:jboss:domain:web:1.1" default-virtual-server="default-host" native="false">

                          <connector name="http" protocol="HTTP/1.1" scheme="http" socket-binding="http"

                              compression="on" compressableMimeType="text/html,text/xml,text/css,text/javascript, application/x-javascript,application/javascript" />

                          <virtual-server name="default-host" enable-welcome-root="true">

                              <alias name="localhost"/>

                              <alias name="example.com"/>

                          </virtual-server>

                      </subsystem>

                       

                      Error :

                       

                      Caused by: javax.xml.stream.XMLStreamException: ParseError at [row,col]:[259,13]

                      Message: JBAS014788: Unexpected attribute 'compression' encountered

                          at org.jboss.as.controller.parsing.ParseUtils.unexpectedAttribute(ParseUtils.java:104) [jboss-as-controller-7.1.1.Final.jar:7.1.1.Final]

                          at org.jboss.as.web.WebSubsystemParser.parseConnector(WebSubsystemParser.java:820)

                          at org.jboss.as.web.WebSubsystemParser.readElement(WebSubsystemParser.java:325)

                          at org.jboss.as.web.WebSubsystemParser.readElement(WebSubsystemParser.java:65)

                          at org.jboss.staxmapper.XMLMapperImpl.processNested(XMLMapperImpl.java:110) [staxmapper-1.1.0.Final.jar:1.1.0.Final]

                      • 8. Re: GZip compression for connector in JBoss 7.0.x
                        varkon

                        To quote from the jira associated with this thread,

                         

                        {quote}-Dorg.apache.coyote.http11.Http11Protocol.COMPRESSION=on{quote}

                         

                        Seems to enable HTTP compression. I'm only re-posting it here for clarity.

                         

                        Thanks.

                        • 9. Re: GZip compression for connector in JBoss 7.0.x
                          hfluz

                          Are you sure Dimitris? I tried running jboss like "./standalone -Dorg.apache.coyote.http11.Http11Protocol.COMPRESSION=on", also tried setting it in the system-properties (standalone.xml), but Pagespeed (firefox addon) changed the compression score from 0 to 2 (out of 100). Is there anything else I should be doing?

                          • 10. Re: GZip compression for connector in JBoss 7.0.x
                            varkon

                            In truth, I've only set the compression flag to "on".

                            My requests contain the "Accept-Encoding: gzip,deflate" header. After setting the flag, my tests reply with "Content-Encoding: gzip".

                            • 11. Re: GZip compression for connector in JBoss 7.0.x
                              hfluz

                              You're right Dimitris, my requests also contain the gzip header, but have you realized any diference? The size of the pages are really smaller? Pagespeed plugin still points me that the compressing is disabled.

                              • 12. Re: GZip compression for connector in JBoss 7.0.x
                                ceefour

                                Check it out for yourself :

                                 

                                ceefour@annafi:~$ curl --raw --compressed -s http://localhost:9080/ -o - | wc -c

                                1259

                                 

                                ceefour@annafi:~$ curl --raw -s http://localhost:9080/ -o - | wc -c

                                2432

                                 

                                So, yes, JBoss 7.1.1 HTTP compression is definitely working for me.

                                • 13. Re: GZip compression for connector in JBoss 7.0.x
                                  silenius

                                  It seems that JBoss AS 7.1.1 HTTP compression only compress the document itself and not static files (e.g., *.js, *.css, ...):

                                  Gzip.png

                                  Is there a way to define which the compressible MimeTypes are?

                                  • 14. Re: GZip compression for connector in JBoss 7.0.x
                                    emollient-mind

                                    Please add the following system properties for enabling gzip and serving gzipped content

                                     

                                    file : standalone.xml  (JBoss AS 7+ )

                                     

                                    Position : right after

                                    <extensions>

                                     

                                    </extensions>

                                     

                                     

                                    <system-properties>

                                            <property name="org.apache.coyote.http11.Http11Protocol.COMPRESSION" value="on"/>

                                            <property name="org.apache.coyote.http11.Http11Protocol.COMPRESSION_MIME_TYPES" value="text/javascript,text/css,text/html,text/xml,text/json"/>  <!-- add other content types you want to gzip -->

                                    </system-properties>

                                     

                                    Note : Please install YSlow firebug plugin to see gzip in action else you may not know even if gzipping is working.

                                     

                                    Appreciate if any idea on enabling pre gzipped js or css serving to browsers in JBoss AS 7 series

                                     

                                    regards

                                    1 2 Previous Next