我试图将Tomcat 7的缓存控制
设置为 no-cache
选项。
我尝试在我的web.xml
中使用ExpiresFilter
,如下所示:
<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>access plus 0 seconds</param-value>
</init-param>
<init-param>
<param-name>ExpiresByType text/css</param-name>
<param-value>access plus 0 seconds</param-value>
</init-param>
<init-param>
<param-name>ExpiresByType application/javascript</param-name>
<param-value>access plus 0 seconds</param-value>
</init-param>
<init-param>
<param-name>ExpiresDefault</param-name>
<param-value>access plus 0 seconds</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>ExpiresFilter</filter-name>
<url-pattern>/*</url-pattern>
<dispatcher>REQUEST</dispatcher>
</filter-mapping>
然而,当我读取响应头时,我得到的只是:
Cache-Control:max-age=0
而不是Cache-Control: no-cache
。
我该如何通过配置文件设置我的Tomcat服务器仅指定Cache-Control: no-cache
?