Configure Jboss EAP 6.1 to GZIP Http response

2.3k Views Asked by At

I tried to compress the Http response by making following changes into the standalone.xml:

<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,application/json"/>
    </system-properties>

But this solution didn't worked. I also passed the "Accept-Encoding:gzip,deflate" header in the request, when I intercepted the http response from server using fiddler it was not compressed.

Please help!

1

There are 1 best solutions below

1
On

Instead of modifying the standalone.xml file try to edit the standalone.conf file and add these lines:

  • JAVA_OPTS="$JAVA_OPTS -Dorg.apache.coyote.http11.Http11Protocol.COMPRESSION=on"
  • JAVA_OPTS="$JAVA_OPTS -Dorg.apache.coyote.http11.Http11Protocol.COMPRESSION_MIME_TYPES=text/javascript,text/css,text/html"
  • JAVA_OPTS="$JAVA_OPTS -Dorg.apache.coyote.http11.Http11Protocol.COMPRESSION_MIN_SIZE=20"

If you are on a unix/linux/macos you can use curl to verify:

curl --raw -i -H "Accept-Encoding: \"gzip,deflate\"" -v http://localhost:8020/sarpsa/

Check on the reponse your server is returning text/javascript, text/css or text/html:

HTTP/1.1 200 OK
Set-Cookie: JSESSIONID=3M16ifxp2tkkrtoc9ZcKTOCr; Path=/application
Content-Type: text/html;charset=iso-8859-1
Transfer-Encoding: chunked
Content-Encoding: gzip
Vary: Accept-Encoding
Date: Thu, 08 Jan 2015 17:28:34 GMT

Otherwise if you are getting some other Content-Type, add it to your list of COMPRESSION_MIME_TYPES