Cache-Control headers problem after updating Spring from 3.0.2 to 3.0.1 release
Hello
I have a problem with Cache-Control headers after updating Spring from 3.0.1 to 3.0.2.
I have a contoller (without annotations) inheriting from MultiActionController :
Code:
public class JsonControler extends MultiActionController{
public ModelAndView getTheme(HttpServletRequest request, HttpServletResponse response) throws Exception {
ModelAndView modelAndView = new ModelAndView();
List<MeaDTO> meaList = getService().getTheme();
modelAndView.addObject(RESPONSE,meaList);
setCacheControl(response, getWebappConfig().getCacheControlByKey("json.getTheme"));
return modelAndView;
}
protected void setCacheControl(HttpServletResponse response, final int pCacheValue) {
if (pCacheValue != -1) {
applyCacheSeconds(response, pCacheValue);
}
response.addHeader("Cache-Control", "stale-while-revalidate=" + webappConfig.getCacheStaleWhileRevalidate());
}
...
}
The url mapping and the url rewriting are defined in the Spring configuration context
file
Code:
<bean id="urlMapping"
class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
<property name="mappings">
<props>
<prop key="/catalog/**/*.do-json">jsonControler</prop>
</props>
</property>
</bean>
Code:
<rule match-type="regex">
<from>^/catalog/home/theme.json$</from>
<to>getTheme.do-json</to>
</rule>
When I specify the cache-control headers with setCacheControl (=> applyCacheSeconds from WebContentGenerator spring bean) there are inconsistent headers.
In Spring 3.0.1, it's OK:
Code:
Expires : Tue, 16 Aug 2011 xxxx GMT
Cache-Control:max-age=1800, stale-while-revalidate=3600
In Spring 3.0.2, it's KO, there are 2 expiration dates and additional cache-control parameters :
Code:
Expires : Tue, 16 Aug 2011 xxxx GMT, Tue, 01 Jan 1970 xxx GMT
Cache-Control:max-age=1800, stale-while-revalidate=3600, no-cache, no-store, max-age=0
Is it a regression of Spring 3.0.2 ?