运行环境 一个内存为4g的window服务器 服务器有点差
方法1.调整tomcat config/server.xml
<Connector port="8080" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443"
executor="tomcatThreadPool"
URIEncoding="utf-8"
compression="on"
useSendfile="false"
compressionMinSize="50"
noCompressionUserAgents="gozilla, traviata"
compressableMimeType="text/html,text/xml,text/javascript,text/css,text/plain" />
方法2.
方法1虽然可以提高效率但会加重tocmat负担,如果有nginx代理的项目可以直接在nginx下配置开启gzip
upstream qt.com{
server 192.168.1.106:18020;
}
gzip on; #开启gzip
gzip_vary on;
gzip_min_length 1k; #不压缩临界值,大于1k的才压缩,一般不用改
gzip_buffers 4 16k;
gzip_comp_level 6; #压缩级别,数字越大压缩的越好
gzip_types text/plain application/javascript application/x-javascript text/css application/xml text/javascript application/x-httpd-php image/jpeg image/gif image/png image/x-icon; #压缩文件类型,缺啥补啥
server {......