ams
ams

Reputation: 62732

Is there a spring 3.1 MVC annotation to turn off browser response caching?

Is there some annotation in SpringMVC 3.1 to turn off browser caching on an MVC controller method?

@Controller
@RequestMapping("/status")
public class StatusController {

    @RequestMapping(method=RequestMethod.GET)
    //anyway to have an annotation here that turns of all the http caching headers?
    public String get()
    {
            // do some work here 
        return "status";
    }
}

Upvotes: 4

Views: 1278

Answers (1)

sourcedelica
sourcedelica

Reputation: 24047

As far as I can tell there isn't an annotation, but there is a way to configure it via XML using an interceptor. For example:

<mvc:interceptors>
    <mvc:interceptor>
        <mvc:mapping path="/status"/>
        <bean id="noCacheWebContentInterceptor"
                      class="com.nyx.spring.mvc.WebContentInterceptor">
            <property name="cacheSeconds" value="0"/>
            <property name="useExpiresHeader" value="true"/>
            <property name="useCacheControlHeader" value="true"/>
            <property name="useCacheControlNoStore" value="true"/>
        </bean>
    </mvc:interceptor>
</mvc:interceptors>

Upvotes: 2

Related Questions