目录
1.项目中启用gzip压缩
2.在feign 服务提供方开启http压缩(很重要)
3.启用httpclient
4.还有一点很容易忽略的,引入httpclient jar包,同时注意和openfeign的版本一致。
一.最近项目要在feign中开启gzip压缩,网上看了好多都是相互抄袭的错误的文章,在这里记录一下我测试可行的方法。
1.项目中启用gzip压缩
compression.request.enabled=true
compression.request.enabled=true
compression.request.mime-types=text/xml,application/xml,application/json
compression.request.min-request-size=2048
compression.response.enabled=true
compression.response.useGzipDecoder=true。
2.在feign 服务提供方开启http压缩(很重要)
server:
compression:
enabled: true
min-response-size: 10
mime-types:
- image/png
- image/jpeg
- image/jpg
- text/html
- application/javascript
- text/css
- application/octet-stream
- application/json
3.启用httpclient
feign:
httpclient:
enabled: true
4.还有一点很容易忽略的,引入httpclient jar包,同时注意和openfeign的版本一致。
io.github.openfeign
feign-httpclient
10.1.0
server:
compression:
enabled: true
min-response-size: 10
mime-types:
- image/png
- image/jpeg
- image/jpg
- text/html
- application/javascript
- text/css
- application/octet-stream
- application/json
3.启用httpclient
feign:
httpclient:
enabled: true
4.还有一点很容易忽略的,引入httpclient jar包,同时注意和openfeign的版本一致。
io.github.openfeign
feign-httpclient
10.1.0
io.github.openfeign feign-httpclient10.1.0
最后做个检查
如果含有gzip压缩,压缩成功



