springboot与tomcat中GZip压缩
tomcat配置压缩
<Connector port="8083" protocol="HTTP/1.1" connectionTimeout="20000" compression="on" compressionMinSize="1024" compressableMimeType="application/json,text/plain" redirectPort="8443" />
springboot配置压缩
server.compression.enabled=true
server.compression.mime-types=application/json,text/plain
server.compression.min-response-size=1024
效果对比
结论
springboot开启Gzip压缩只在作为jar包运行时有效(作为内嵌tomcat的参数),如果在tomcat中运行,以tomcat中配置为准