JimmyLv
4/10/2015 - 4:01 PM

Spring MVC no cache Java

Spring MVC no cache Java

public class WebMvcConfig
    extends WebMvcConfigurerAdapter {
    
    ...

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addIntercetpro(this.webContentInterceptor());
        super.addInterceptors(registry);
    }

    public WebContentInterceptor webContentInterceptor() {
        WebContentInterceptor interceptor = new WebContentInterceptor();
        interceptor.setCacheSeconds(0);
        interceptor.setUseExpiresHeader(true);;
        interceptor.setUseCacheControlHeader(true);
        interceptor.setUseCacheControlNoStore(true);
        return interceptor;
    }
}