mod_expires 모듈 추가 및 이미지 캐싱 설정방법

by 조쉬 posted Feb 27, 2014
?

단축키

Prev이전 문서

Next다음 문서

ESC닫기

크게 작게 위로 아래로 댓글로 가기 인쇄
DSO 모듈로 설치되 있을 경우 재컴파일 없이 모듈추가 가능합니다.
1. 기설치된 버전에 아파치 압축해제 후 모듈폴더로 이동
#tar zxvf ./httpd-2.x.x.tar.gz
#cd httpd-2.x.x/modules/mappers
2. 모듈컴파일
#/usr/local/httpd/bin/apxs -a -i -c mod_expires.c
3. 모듈생성확인 후 httpd.conf 파일에 모듈 추가
#cd /usr/local/httpd/modules 폴터에 mod_expires 파일 확인
#vi /usr/local/httpd/conf/httpd.conf 파일에
LoadModule expires_module modules/mod_expires.so 라인추가
4. httpd.conf 설정파일 확인후 아파치 재시작
#/usr/local/httpd/bin/apachectl configrest
#/usr/local/httpd/bin/apachectl restart



2. mod_expires 설정
이미지 서버에 지정한 다음 예를 보자.

    ExpiresActive On
    ExpiresDefault "access plus 1 month"

   # 제외할 디렉토리
    
    ExpiresActive Off
    


- ExpiresActive On 지시자로 Expires 설정을 enable 한다.
- ExpiresDefault "access plus 1 month" 지시자는 액세스한지 얼마나 지나서 expire할 것인지를 지정한다. 즉, 지정한 기간만큼 클라이언트에 캐싱이 된다. 위에는 1달이다.
이외에 클라이언트에서 액세스한지 1달, 4주, 30일, 1년 등과 같은 expire 주기와 서버의 파일의 수정 시간으로 expire 주기를 설정할 수 있다.
ExpiresDefault "access plus 1 month"
ExpiresDefault "access plus 4 weeks"
ExpiresDefault "access plus 30 days"
ExpiresDefault "access plus 1 years"
ExpiresDefault "modification plus 30 days"
설정 마지막부분에 Directory 지시자와 ExpiresActive Off 설정을 통해 특정 디렉토리만 expire 설정에서 제외할 수 있다.
반대로 특정 디렉토리만 On으로도 설정할 수 있다. (일반 웹서버에 /images 와 같이 디렉토리가 있는 경우)
ExpiresByType image/gif "access plus 4 weeks"
ExpiresByType text/html "access plus 1 weeks"
- 위처럼 파일의 유형으로도 가능하다.


3. 확인





IE의 경우 '도구 > 인터넷 옵션 > 임시인터넷파일 > 설정 > 파일보기'에서 확인이 가능합니다.
참고로 [다음(daum)] 의 이미지 서버는 28일(4주)로 [야후!코리아] 는 5년으로 설정되어 있다.