Spring Boot or Tomcat caches my static assets .js and .css files in development environment and I have to Build -> Build Project (in IntelliJ) every time to get the refreshed version.
I tried these application properties and they didn't work.
spring.resources.cache-period=0
spring.resources.chain.cache=false
spring.resources.chain.html-application-cache=false
spring.resources.chain.strategy.content.enabled=false
spring.resources.chain.strategy.content.paths=/**
I tried to have this bean to configure Tomcat and it didn't work as well:
@Bean
public EmbeddedServletContainerFactory servletContainer() {
TomcatEmbeddedServletContainerFactory tomcatFactory = new TomcatEmbeddedServletContainerFactory() {
@Override
protected void postProcessContext(Context context) {
final int cacheSize = 0;
StandardRoot standardRoot = new StandardRoot(context);
standardRoot.setCachingAllowed(false);
standardRoot.setCacheMaxSize(cacheSize);
context.setResources(standardRoot);
}
};
return tomcatFactory;
}
When changing js and css files I don't want to do Build Project every time, I can even use something like BrowserSync to apply changes automatically to the web page but for that I need Tomcat/Spring to serve static assets in dev environment without me clicking to Build Project.
The doc is not really helpful and according to the doc there is no way except clicking Build every single time changing a css or js file. http://docs.spring.io/spring-boot/docs/current-SNAPSHOT/reference/htmlsingle/#howto-hotswapping
But I believe this should be something very simple and perfectly achievable isn't it.
Any ideas what should I try next?
Thanks