Springboot启用Gzip

有个接口数据量比较大,大概3M,每次访问时长都在1s甚至3s以上。后台监控显示数据查询只有100ms,传输占据了大量时间。

考虑没开启压缩,尝试开启gzip。 在springboot添加如下设置:


server:
  servlet:
    context-path: /api
  compression:
    enabled: true
    mime-types: application/json,application/xml,text/html,text/xml,text/plain

由于都是类似的纯文本,压缩比很惊人, 压缩后只有几百k, 接口耗时一下进入毫秒级别。

原文地址:https://www.cnblogs.com/woshimrf/p/springboot-enable-gzip.html