TOMCAT에서 image나 js, css 같은 파일 캐싱하기.

필터 설정을 통해 정적 파일들을 캐싱해보자.

<filter>
        <filter-name>ExpiresFilter</filter-name>
        <filter-class>org.apache.catalina.filters.ExpiresFilter</filter-class>
        <init-param>
                <param-name>ExpiresByType image</param-name>
                <param-value>A2592000 </param-value>
        </init-param>
        <init-param>
                <param-name>ExpiresByType text/css</param-name>
                <param-value>A1800</param-value>
        </init-param>
        <init-param>
                <param-name>ExpiresByType application/javascript</param-name>
                <param-value>A1800</param-value>
        </init-param>
</filter>
<filter-mapping>
        <filter-name>ExpiresFilter</filter-name>
        <url-pattern>/*</url-pattern>
        <dispatcher>REQUEST</dispatcher>
</filter-mapping>

web.xml의 <web-app></web-app> 사이에 넣어주면 된다.

댓글 남기기