1

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"
            connectionTimeout="20000"
            redirectPort="8443" 
            compression="force"
            compressionMinSize="2048"
            compressableMimeType="text/html,text/xml,application/javascript,text/css"/>

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

What could be the reason behind that?

Thanks, Bernhard

1 Answer 1

3

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

useSendfile="false"

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+).

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.