DD.
DD.

Reputation: 21991

Tomcat7 Compression JS/CSS

I've enabled compression using the following setting in my tomcat7 server.xml:

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

I've checked that compression is now switched on using: http://www.whatsmyip.org/http-compression-test/

However, PageSpeed still reports that several CSS/JS files are not being compressed. e.g. Compressing http://www.mysite.co.uk/css/bootstrap.css could save 109.5KiB (84% reduction).

Upvotes: 3

Views: 3397

Answers (1)

stan
stan

Reputation: 4995

Are all the CSS/JS files that are not compressed relatively large? Maybe those are sent by "sendfile" and thus avoid being compressed.

In the documentation:

"Note: There is a tradeoff between using compression (saving your bandwidth) and using the sendfile feature (saving your CPU cycles). If the connector supports the sendfile feature, e.g. the NIO connector, using sendfile will take precedence over compression. The symptoms will be that static files greater that 48 Kb will be sent uncompressed. You can turn off sendfile by setting useSendfile attribute of the connector, as documented below, or change the sendfile usage threshold in the configuration of the DefaultServlet in the default conf/web.xml or in the web.xml of your web application."

http://tomcat.apache.org/tomcat-6.0-doc/config/http.html

Set in your config:

useSendfile="false"

Upvotes: 2

Related Questions