아파치 mod_expires 설정 및 활용
▶mod_expires.c 설치
/usr/local/apache/bin/apxs -aic /usr/local/src/httpd-2.2.14/modules/metadata/mod_expires.c
▶httpd.conf 에 내용추가
LoadModule expires_module libexec/mod_expires.so
<IfModule mod_expires.c>
ExpiresActive On
ExpiresDefault "access plus 1 month"
ExpiresByType application/javascript "access plus 1 month"
ExpiresByType text/css "access plus 1 month"
ExpiresByType image/jpeg "access plus 1 month"
ExpiresByType image/gif "access plus 1 month"
ExpiresByType image/png "access plus 1 month"
<Directory "/usr/local/apache/htdocs">
ExpiresActive Off
</Directory>
</IfModule>
▶추가
ExpiresByType application/x-javascript "access plus 1 month"
ExpiresByType text/css "access plus 1 month"
ExpiresByType image/jpeg "access plus 1 month"
ExpiresByType image/gif "access plus 1 month"
ExpiresByType image/png "access plus 1 month"
ExpiresByType image/bmp "access plus 1 month"
ExpiresByType image/cgm "access plus 1 month"
ExpiresByType image/tiff "access plus 1 month"
ExpiresByType video/mpeg "access plus 1 month"
ExpiresByType video/quicktime "access plus 1 month"
ExpiresByType video/x-msvideo "access plus 1 month"
ExpiresByType audio/basic "access plus 1 month"
ExpiresByType audio/midi "access plus 1 month"
ExpiresByType audio/mpeg "access plus 1 month"
ExpiresByType audio/x-aiff "access plus 1 month"
ExpiresByType audio/x-mpegurl "access plus 1 month"
ExpiresByType audio/x-pn-realaudio "access plus 1 month"
ExpiresByType audio/x-wav "access plus 1 month"
ExpiresByType application/x-shockwave-flash "access plus 1 month"
▶아파치 재시작
/usr/local/apache/bin/apachectl restart
※주의
DSO 방식으로 설치된 아파치만 적용가능
설정
<VirtualHost *>
ServerName img.xxxxxx.co.kr
DocumentRoot /home/test/www
#########이미지(gif/jpeg) 캐싱 한달로 설정#############
<Directory "/home/auction/www/img">
ExpiresActive On
ExpiresByType image/jpeg "acces plus 1 month"
ExpiresByType image/gif "acces plus 1 month"
</Directory>
################################################
</VirtualHost>
작동 확인
lynx -head http://img.xxxxxx.com/img/204630001160317126.jpg --> 결과에서 'Cache-Control:' 헤더 부분 확인
Date: Tue, 12 Dec 2006 07:40:21 GMT
Server: Apache
Last-Modified: Sun, 08 Oct 2006 14:18:46 GMT
ETag: "76962b-23516-621f3d80"
Accept-Ranges: bytes
Content-Length: 144662
Cache-Control: max-age=2592000
Expires: Thu, 11 Jan 2007 07:40:21 GMT
Connection: close
Content-Type: image/jpeg
max-age=86400이면 하루이다.
[출처] WEB | superman4u (http://blog.naver.com/superman4u?Redirect=Log&logNo=40101316345)
2592000은 30일
'리눅스 > APACHE' 카테고리의 다른 글
mod_rewrite 를 이용한 주소 단축 (0) | 2015.01.16 |
---|---|
아파치 user, group 을 root 권한으로 설정 (0) | 2015.01.16 |
이미지 링크 방지 설정하기 (0) | 2015.01.16 |
Tomcat 관리자 tomcat administration, tomcat manager 설정하기 (0) | 2015.01.16 |
tomcat 5.5.9 에 admin 설치 하기 (0) | 2015.01.16 |