yur*_*ura 19 java spring tomcat caching spring-mvc
如何使用Tomcat启用静态内容(images,css,js)的浏览器缓存?优选的解决方案是editingspring MVC配置文件或web.xml
Boz*_*zho 23
尝试(改变值)
<mvc:resources mapping="/static/**" location="/public-resources/"
cache-period="31556926"/>
<mvc:annotation-driven/>
Run Code Online (Sandbox Code Playgroud)
你也可以使用一个拦截器:
<mvc:interceptors>
<mvc:interceptor>
<mvc:mapping path="/static/*"/>
<bean id="webContentInterceptor"
class="org.springframework.web.servlet.mvc.WebContentInterceptor">
<property name="cacheSeconds" value="31556926"/>
<property name="useExpiresHeader" value="true"/>
<property name="useCacheControlHeader" value="true"/>
<property name="useCacheControlNoStore" value="true"/>
</bean>
</mvc:interceptor>
</mvc:interceptors>
Run Code Online (Sandbox Code Playgroud)
请参阅MVC文档
| 归档时间: |
|
| 查看次数: |
14911 次 |
| 最近记录: |