gzip 을 사용할 경우, 웹서버와 클라이언트(브라우저)의 CPU 사용량이 약간 늘어난다. 요즘 서버나 PC의 경우 충분히 고사양이기 때문에 gzip cpu 사용량은 무시해도 된다.(0.1% 미만)
압축 전송이기 때문에 전송속도가 빨라지고 , 트래픽량이 줄어든다. 특히, 국가간 트래픽이나 느린 인터넷 환경에서, 속도가 빨라진 것을 크게 느낄 수 있다.
너무 작은 파일은 그냥 전송하는게 더 빠르고, 이미 충분히 압축된 파일은 gzip 을 해도 용량이 별로 안줄어들기 때문에 gzip 압축 전송을 안 쓰는 것이 좋다.
항상, 텍스트 데이터는 압축효율이 좋다.
일반적으로, 바이너리 데이터는 압축효율이 좋지 않다. 압축 후 데이터 크기가 더 커질 수 있다.
Image, video, pdf, zip 등은 이미 충분히 압축된 바이너리 파일이므로 gzip 을 적용하면 안된다. (데이터 크기가 줄어든다는 보장이 없고, 불필요한 압축 & 해제 단계가 추가된다. 당연한 이야기지만 데이터 사이즈가 커질수록 cpu 사용량이 늘어난다. )
내가 개인적으로 설정한것
gzip on;
gzip_proxied any;
gzip_min_length 10240;
gzip_buffers 32 32k;
gzip_comp_level 9;
gzip_types text/plain application/x-javascript application/javascript text/javascript text/xml text/css application/json;
gzip_vary on;
Reference
위키노트/Nginx 압축 전송 설정
Nginx에서 압축 전송을 하려면 http 블록에 아래 내용을 추가한다. gzip_types 지시자의 기본값은 text/html이다. gzip_types 지시자에 값을 설정하면 Nginx는 기본값인 text/html에 설정한 값을 추가해서 지정
bigforest.miraheze.org
https://www.lesstif.com/system-admin/nginx-gzip-59343019.html
nginx 에 gzip 으로 컨텐츠 압축 설정하기
www.lesstif.com
https://blog.lael.be/post/6553
NGINX Gzip 설정하기
* GZIP 이란? Gzip 은 GNU zip 의 줄임말이며 리눅스/유닉스 시스템에서 널리쓰이는 압축 소프트웨어 이다. 웹서버 통신을 할 떄 데이터를 gzip 압축하여 전송하면 속도가 더 빨라진다. * gzip 사용 안할
blog.lael.be
#gzip on;
gzip on;
gzip_min_length 10240;
gzip_buffers 32 32k;
gzip_comp_level 9;
gzip_types text/plain application/x-javascript text/xml text/css application/json;
gzip_vary on;
# end gzip configuration
옵션설명 vary
https://yangbongsoo.tistory.com/4
nginx gzip 옵션
응답을 압축하면 전송되는 데이터의 크기가 크게 줄어들기도 한다. 그러나 압축은 런타임에 발생하기 때문에 상당한 처리 오버헤드가 추가되어 성능에 부정적인 영향을 미칠 수 있다. nginx는 클
yangbongsoo.tistory.com
공식문서 설명
http://nginx.org/en/docs/http/ngx_http_gzip_module.html#gzip_min_length
Module ngx_http_gzip_module
Module ngx_http_gzip_module The ngx_http_gzip_module module is a filter that compresses responses using the “gzip” method. This often helps to reduce the size of transmitted data by half or even more. When using the SSL/TLS protocol, compressed respons
nginx.org
content-type 크기에 따라 압축전송이 되거나 안됨?
Why is the gzip minimum length directive not being respected?
If I understand correctly it's better not to gzip small resources as they might actually get bigger while still having a performance hit on the CPU. So using the gzip_min_length directive is an obv...
stackoverflow.com
gzip_types
https://developer.mozilla.org/en-US/docs/Learn/Server-side/Configuring_server_MIME_types
Properly configuring server MIME types - Learn web development | MDN
MIME types describe the media type of content, either in email, or served by web servers or web applications. They are intended to help provide a hint as to how the content should be processed and displayed.
developer.mozilla.org
https://stackoverflow.com/questions/23939722/nginx-gzip-not-compressing-javascript-files
NGINX gzip not compressing JavaScript files
All JavaScript files are not compressed by nginx gzip. CSS files are working. In my nginx.conf I have the following lines: gzip on; gzip_disable "MSIE [1-6]\.(?!.*SV1)"; gzip_proxied any; gzip_b...
stackoverflow.com
'WEB,WAS > Nginx' 카테고리의 다른 글
nginx ssl 갱신 설정 (0) | 2023.05.31 |
---|---|
nginx forbidden 403 error 에러 (0) | 2023.02.16 |
nginx 업로드 파일 size 변경 (0) | 2023.02.08 |
[Nginx]upstream timed out, no live upstreams (0) | 2023.01.12 |
Nginx 에서 환경변수를 지원할까요? (0) | 2022.12.19 |
댓글