스프링에서 응답하는 메시지 크기를 압축하기 위해서 스프링 설정 파일에서 값들을 설정할 수 있다. .yml
파일이나 .properties
파일에서 해당 값을 설정한다.
server:
compression:
enabled: true
min-response-size: 10
mime-types: "text/html"
server.compression.enabled
: 응답 메시지에서 압축을 할지에 대한 여부를 설정한다.server.compression.min-response-size
: 압축을 실행할 최소 사이즈를 설정한다. 기본 값은 2KB(2048 bytes) 이며 값의 단위는 bytes 이다.server.compression.mime-types
: 압축할 파일의 MIME_TYPE 을 설정한다. 해당 값을 설정하면 특정 타입에 대한 파일만 압축을 실행할 수 있다.응답 메시지가 압축되었을 경우 HTTP 응답 메시지 헤더에 "Transfer-Encoding"
의 값이 "chunked"
로 표신된다.
https://docs.spring.io/spring-boot/docs/current/reference/htmlsingle/#howto.webserver.enable-response-compression