WebContentIntercepter
static URL 은 우리가 직접 header 를 만들지 않기 때문에 header 의 속성을 변경하려면 어떻게 해야하나 고민이 된다. 그런데 ref. 1 에서 좋은 방법을 알려줬다.
스프링에서 제공하는 Interceptor 중에 WebContentIntercepter 를 이용하면 된다.
org.springframework.web.servlet.mvc.WebContentInterceptor
그런데 ref. 2 를 보니 간단하게 <mvc:resources> 의 attribute 에서 설정할 수 있다. attribute 이름은 cache-period 이다.
사용
만약 /resources/pages/ 안에 있는 모든 static URL 의 cache 를 no cache 로 하고 싶다면 아래와 같이 설정해 주면 된다.<mvc:interceptors>
<mvc:interceptor>
<mvc:mapping path="/resources/pages/*"/>
<bean id="webContentInterceptor"
class="org.springframework.web.servlet.mvc.WebContentInterceptor">
<property name="cacheSeconds" value="0"/>
<property name="useExpiresHeader" value="true"/>
<property name="useCacheControlHeader" value="true"/>
<property name="useCacheControlNoStore" value="true"/>
</bean>
</mvc:interceptor>
</mvc:interceptors>
댓글 없음:
댓글 쓰기