Cannot turn on gzip compression in JBoss 5

2019-06-14 10:02发布

问题:

I added following file
deployers\jbossweb.deployer\server.xml

<Connector compression="force" 
   compressionMinSize="512" 
   noCompressionUserAgents="gozilla, traviata" 
   compressableMimeType="text/html,text/xml,image/png,text/css,text/javascript">
</Connector>

But fiddler shows that jboss does not compress responses.

How to ensure that gzip compression in JBoss is turned on?
Is it possible to check it in jmx-console?

回答1:

Those settings need to be added to your existing HTTP connector element, i.e.:

  <Connector port="8080" address="${jboss.bind.address}"
     maxThreads="250" strategy="ms" maxHttpHeaderSize="8192"
     emptySessionPath="true"
     enableLookups="false" redirectPort="8443" acceptCount="100"
     connectionTimeout="20000" disableUploadTimeout="true"
  <!-- compression settings -->
     compression="force" 
     compressionMinSize="512" 
     noCompressionUserAgents="gozilla, traviata" 
     compressableMimeType="text/html,text/xml,image/png,text/css,text/javascript"
  />

Just adding them to a new <Connector> with no other settings won't do you any good.