spring web developement - disable caching for static content
<p>I'm developping a angularjs application with Spring.</p>

<p>I often have to change my html/javascript file and I noticed that spring is caching static contents. How can I disable that?</p>

<p>I already tried this ...</p>

<pre><code>@Configuration
@AutoConfigureAfter(DispatcherServletAutoConfiguration.class)
class WebMvcConfig extends WebMvcAutoConfiguration.WebMvcAutoConfigurationAdapter {

    @Autowired
    private Environment env;

    @Bean
    public ResourceUrlEncodingFilter resourceUrlEncodingFilter() {
        return new ResourceUrlEncodingFilter();
    }

    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        boolean devMode = this.env.acceptsProfiles("dev");
        //boolean useResourceCache = !devMode;
        boolean useResourceCache = false;
        Integer cachePeriod = devMode ? 0 : null;

        registry.addResourceHandler("/public/**")
                .addResourceLocations("/public/", "classpath:/public/")
                .setCachePeriod(cachePeriod)
                .resourceChain(useResourceCache)
                .addResolver(new GzipResourceResolver())
                .addResolver(new VersionResourceResolver().addContentVersionStrategy("/**"))
                .addTransformer(new AppCacheManifestTransformer());
    }

}
</code></pre>

<p>and that ...</p>

<pre><code>WebContentInterceptor webContentInterceptor;
public @Bean WebContentInterceptor webContentInterceptor () {
    if (this.webContentInterceptor == null) {
        this.webContentInterceptor = new WebContentInterceptor();

        this.webContentInterceptor.setAlwaysUseFullPath (true);
        this.webContentInterceptor.setCacheSeconds (0);


        this.webContentInterceptor.setCacheMappings (new Properties() {
            private static final long serialVersionUID = 1L;

            {
                put ("/styles/**", "0");
                put ("/scripts/**", "0");
                put ("/images/**", "0");
                put ("/js/**", "0");
            }
        });
    }

    return this.webContentInterceptor;
}
</code></pre>

<p>this is my build.gradle file</p>

<pre><code>group 'xyz'
version '1.0-SNAPSHOT'
buildscript{
    repositories{
        mavenCentral()
    }
    dependencies{
        classpath("org.springframework.boot:spring-boot-gradle-plugin:1.3.2.RELEASE")
    }
}

apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'idea'
apply plugin: 'spring-boot'

sourceCompatibility = 1.8
targetCompatibility = 1.8

repositories {
    mavenCentral()
    maven { url "https://repository.jboss.org/nexus/content/repositories/releases" }
}

dependencies {
    compile 'org.springframework.boot:spring-boot-starter-web'
    compile 'org.springframework.security:spring-security-web:4.0.3.RELEASE'
    compile 'net.sf.dozer:dozer:5.4.0'

    compile 'org.springframework.boot:spring-boot-starter-data-jpa'
    compile 'com.h2database:h2'// For Testing purpose
    compile 'com.google.guava:guava:19.0' // google library for data collections

    testCompile("junit:junit")
    //testCompile group: 'junit', name: 'junit', version: '4.11'
}

task wrapper(type: Wrapper){
    gradleVersion = '2.3'
}

configurations.all {
    // https://stackoverflow.com/questions/14024756/slf4j-class-path-contains-multiple-slf4j-bindings/25694764#25694764
    exclude module: 'slf4j-log4j12'
}
</code></pre>