我们可以为特定的uri启用spring引导压缩吗?

h22fl7wq  于 2021-07-03  发布在  Java
关注(0)|答案(1)|浏览(252)

在我们的javaspringboot应用程序中,我们需要压缩rest响应,因为json结构非常庞大。在浏览web时发现,我们可以在application.properties中使用以下属性来启用压缩。


# Enable response compression

server.compression.enabled=true

# Minimum response where compression will kick in

server.compression.min-response-size=4096

# Mime types that should be compressed

server.compression.mime-types=text/html, text/xml, text/plain, text/css, text/javascript, application/javascript, application/json

它工作得很好,但是它压缩了从服务器返回的所有响应。
有没有办法过滤掉这种压缩。例如,我们只希望压缩uri以compress或merge结尾的响应
或者如果有其他的建议来达到同样的效果。
谢谢您

b5buobof

b5buobof1#

将自定义用户代理添加到要在“属性”的“排除的用户代理”中进行筛选和配置的请求中。接下来将该用户代理放入请求中。

相关问题