gzip:: 아파치,nginx 설정으로 웹페이지 로딩 속도를 빠르게

프론트 성능 개선

프론트 성능개선을 위해 많이 쓰이는 것중 하나가 바로 Gzip
서버에서 html, javascript, css 등을 압축해줘서 리소스를 받는 로딩시간을 줄여줌으로서 성능 개선
예전 프로젝트에서 Gzip에 minify나 concat, cache을 더하여 적용하였더니 이전보다 약 85%의 성능향상이 있었습니다. 웹개발을 하게 되면 필수적인 옵션이라고 할 수 있습니다.

Gzip - 위키피디아

gzip은 파일 압축에 쓰이는 응용 소프트웨어이다. gzip은 GNU zip의 준말이며, 초기 유닉스 시스템에 쓰이던 압축 프로그램을 대체하기 위한 자유 소프트웨어이다. gzip은 Jean-loup Gailly와 마크 애들러가 만들었다. 버전 0.1은 1992년 10월 31일에 처음 공개되었으며, 버전 1.0이 1993년 2월에 뒤따라 나왔다. 오픈BSD의 gzip 버전은 더 오래된 압축 프로그램을 기반으로 하고 있으며, 오픈BSD 3.4에 추가되었다.

아파치 설정

  1. LoadModule deflate_module modules/mod_deflate.so 주석 해제
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
<IfModule mod_deflate.c>

        AddOutputFilterByType DEFLATE text/plain
        AddOutputFilterByType DEFLATE text/html
        AddOutputFilterByType DEFLATE text/xml
        AddOutputFilterByType DEFLATE text/css
        AddOutputFilterByType DEFLATE application/xml
        AddOutputFilterByType DEFLATE application/xhtml+xml
        AddOutputFilterByType DEFLATE application/rss+xml
        AddOutputFilterByType DEFLATE application/javascript
        AddOutputFilterByType DEFLATE application/x-javascript

        DeflateCompressionLevel 9

        BrowserMatch ^Mozilla/4 gzip-only-text/html
        BrowserMatch ^Mozilla/4\.0[678] no-gzip
        BrowserMatch \bMSIE !no-gzip !gzip-only-text/html

        SetEnvIfNoCase Request_URI \.(?:gif|jpe?g|png|bmp|zip|gz|rar|7z)$ no-gzip dont-vary
</IfModule>

nginx설정

1
2
3
4
gzip  on;
gzip_disable "msie6";
gzip_comp_level 9;
gzip_types text/plain text/css application/javascript application/json;

Comments