본문 바로가기
IT/web

[http] gzip 테스트

by 내일은교양왕 2024. 4. 24.

웹 성능에 필수 요소인 gzip 압축에 대해 알아보자

압축 시 손실이 없고 웹서버에서 압축하고 브라우저에서 푼다. 

네트워크 비용을 최소화 하기 위한 노력이다.

 

Request Header에 Accept-Encoding: gzip으로 설정하면 클라이언트가 gzip으로 압축된 컨텐츠를 내려줘도 이해할 수 있다라는 뜻이고, 이걸 받은 서버는 content neogitiation을 통해 제안받은 인코딩 타입 중 하나를 선택해서 Content-Encoding: gzip 으로 내려준다.

 

gzip으로 요청했을 때와 plain text로 요청했을 때 응답을 비교해보자

 

평문 요청

curl -H "Accept-Encoding: identity" https://map.yahoo.co.jp/v2/place/vwRRFUg0gks

 

 

gzip으로 요청

curl -H "Accept-Encoding: gzip" https://map.yahoo.co.jp/v2/place/vwRRFUg0gks

 

파일 크기

파일 크기가 80%정도 감소한걸 눈으로 볼 수 있다.

-rw-r--r--    1 user  staff   142K  4 23 17:36 not_compressed.html
-rw-r--r--    1 user  staff    30K  4 23 17:36 compressed.html

 

https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Accept-Encoding

 

Accept-Encoding - HTTP | MDN

The Accept-Encoding request HTTP header indicates the content encoding (usually a compression algorithm) that the client can understand. The server uses content negotiation to select one of the proposals and informs the client of that choice with the Conte

developer.mozilla.org

 

'IT > web' 카테고리의 다른 글

[http] MIME  (0) 2024.05.10
[FE] async / await  (0) 2024.04.29
[css] Block Formatting Context (BFC)  (0) 2024.04.22
[css] :nth-child  (0) 2024.04.22
[css] body에 배경을 변경했을 때  (0) 2024.04.22