HTTP gzip compression not working for css or javascript in tomcat 6
Solution 1
You should use compressableMimeType
, not compressionMimeType, so
<Connector ...
compression="1400"
noCompressionUserAgents="gozilla, traviata"
compressableMimeType ="text/html,text/xml,text/plain,text/css,text/javascript"/>
Should do the trick.
Solution 2
http://tomcat.apache.org/tomcat-7.0-doc/config/http.html
Please use application/javascript instead of text/javascript, as given below:
compressableMimeType="text/html,text/xml,text/plain,text/css,application/javascript"
Related videos on Youtube
user267202
I am a software developer with a CS background. While my background in CS has armed me with the techniques, algorithms and tools to do my job; creating useful software for a real business requires a greater knowledge of both the problem domain and effective working practices than of the latest and greatest algorithms. I'm very much into learning things from the ground up. I think that learning assembly language and C has made me a much better programmer.
Updated on September 17, 2022Comments
-
user267202 over 1 year
Connector settings:
<Connector ... compression="2048" noCompressionUserAgents="gozilla, traviata" compressionMimeType="text/html,text/xml,text/plain,text/css,text/javascript"/>
This seems to work for html, but not for css or javascript. compression="force" does work, but compression="on" doesn't. compression="2" doesn't work either, so I don't know what "force" is really doing.
The files in question are about 6k, I've cleared the browser cache, etc.
-
Admin over 8 yearsNote that in Tomcat 7 this is the default setting, with the addition of
application/javascript
.
-