Yesterday I asked this question and got some very good feedback. To summarize my situation, I am trying to add cache-prohibiting HTTP response headers to my Spring MVC web app (a project I inherited unexpectedly).
So, per the answer-er's (and ultimately, @Bozho's) suggestion, I added this to my Spring config file:
<mvc:annotation-driven/>
<mvc:interceptors>
<bean id="webContentInterceptor" class="org.springframework.web.servlet.mvc.WebContentInterceptor">
<property name="cacheSeconds" value="-1"/>
<property name="useExpiresHeader" value="true"/>
<property name="useCacheControlHeader" value="true"/>
<property name="useCacheControlNoStore" value="true"/>
</bean>
</mvc:interceptors>
I re-built my app locally, and opened it up in Firefox so I could use Firebug to test the headers coming back with the HTTP responses.
Unfortunately for me, the original developers aimed to make this a "1-page web app" with about 40+ AJAX calls per actual JSP page.
Not only do I not see the headers I'm looking for Cache-Control
, Expires
, etc. in any of these 40+ AJAX requests, but I'm concerned that since there's more than 1 AJAX request per JSP page, the Spring interceptor doesn't know which AJAX calls to add the headers to. I'm not seeing any error messages or logging output to indicate Spring doesn't like my configuration, etc. Everything seems to be acting fine...its just not working!
- Have I configured this incorrectly; if not, what would be the reason why this isn't working (why the interceptor isn't kicking in)?
- Do multiple AJAX calls cause Spring MVC request interceptors to behave strangely?
Thanks in advance for any help here!