Bernie Bernie - 1 year ago 105
CSS Question

Tomcat and compression: CSS/JS compression works ... sometimes

I have a strange problem with my Tomcat 7 (both on Ubuntu and on Windows 7, no Apache in front of Tomcat) compressing CSS/JS.

It works sometimes:
I have a big third party CSS (comprising of Bootstrap, Angular) and JS (Bootstrap, Angular, JQuery), which is NOT compressed. Tomcat doesn't send an

content-encoding: gzip

But my very own CSS/JS are gzipped, as they should (Tomcat sends an content-encoding: gzip to browser in this case).

So this is the server.xml of my Tomcat:

<Connector port="8080" protocol="HTTP/1.1"

So in short:
js/thirdParty.js is uncompressed: FAIL!,
js/own.js is compressed: OK

What could be the reason behind that?


Answer Source

I found it out by myself. I have to add the attribute


to the Connector tag. If I don't, Tomcat will not compress files greather than 48kb (when I use NIO, which is standard for Tomcat7+).

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download