2

我们已经设置了一个 cacheMappings 属性来缓存一个在我们的 Spring MVC 应用程序中永远不会改变的静态 HTML 文件。

<beans:bean id="webContentInterceptor" class="org.springframework.web.servlet.mvc.WebContentInterceptor">
<beansroperty name="cacheSeconds" value="0"/>
<beansroperty name="useExpiresHeader" value="true"/>
<beansroperty name="useCacheControlHeader" value="true"/>
<beansroperty name="useCacheControlNoStore" value="true"/>
<beansroperty name="cacheMappings">
    <beansrops>
        <beansrop key="/foo/**/*.html">31556926</beansrop>
    </beansrops>
</beansroperty>

除了设置一个非常长的缓存期之外,有没有更好的方法来告诉它永远不会使这个特定目录中的 HTML 文件过期?

4

1 回答 1

0

WebCotextInterceptor 将这些参数直接映射到使用时间作为缓存内容到期条件的 http 标头。

更重要的是,规格。说“为了将响应标记为“永不过期”,源服务器在发送响应后大约一年发送一个过期日期。HTTP/1.1 服务器不应该在未来一年以上发送过期日期。

所以 cacheSeconds 值应该是大约。一年遵循规范。

http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.21

附言。看起来您粘贴的代码已损坏或仅包含拼写错误。

于 2013-05-16T08:53:03.150 回答