There are two ways of doing this.
using WebMVCConfig.
using application.properties file
WebMVCConfig.
Create template resolver as this.
@Bean
public TemplateResolver templateResolver()
{
FileTemplateResolver templateResolver = new FileTemplateResolver();
templateResolver.setTemplateMode( "HTML5" );
templateResolver.setCacheable( Boolean.FALSE );
templateResolver.setOrder( 1 );
return templateResolver;
}
Application properties
add following line to application.properties file
spring.thymeleaf.cache: false
I saw other solution
@Bean
public WebMvcConfigurer configurer () {
return new WebMvcConfigurer() {
@Override
public void addResourceHandlers(ResourceHandlerRegistry registry) {
registry.addResourceHandler("/resources/**")
.addResourceLocations("/resources/")
.setCachePeriod(31556926);
}
};
}
For reference: headers-cache-control But still doesn't work for me. I am using Spring Boot Security also.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.