springboot 静态资源缓存设置

springboot 静态资源 js css  缓存设置

@Configuration
public class WebMvcConfiguration implements WebMvcConfigurer {

    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        registry
            .addResourceHandler("/resources/**")
            .addResourceLocations("/resources/")
            .setCachePeriod(31556926);

        registry.addResourceHandler("/webjars/**")
                .addResourceLocations("/webjars/")
                .setCachePeriod(31556926);
    }


}

springboot 静态资源缓存设置_第1张图片

https://docs.spring.io/spring-security/site/docs/5.1.2.RELEASE/reference/htmlsingle/#headers-cache-control

你可能感兴趣的:(springboot)