在 SpringBoot 中启用 GZIP 压缩
打开application.yml文件,添加如下配置
server: compression: enabled: true min-response-size: 1024 mime-types: application/javascript,text/css,application/json,application/xml,text/html,text/xml,text/plain
|
在tomcat中开启GZIP压缩
打开 Tomcat 的 server.xml,在 Connector 标签中加入下面属性
<Connector port="8080" protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="8443" compression="on" compressionMinSize="2048" noCompressionUserAgents="gozilla, traviata" compressableMimeType="text/html,text/xml,text/javascript,application/javascript,text/css,text/plain,text/json"/>
|