Skip to content

Instantly share code, notes, and snippets.

@guaracyalima
Created November 13, 2024 04:11
Show Gist options
  • Save guaracyalima/1fff72864d7851c8d35afdffb7ad7c60 to your computer and use it in GitHub Desktop.
Save guaracyalima/1fff72864d7851c8d35afdffb7ad7c60 to your computer and use it in GitHub Desktop.
package br.com.zeroth.zth_product_srv.config;
import jakarta.servlet.Filter;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.CacheControl;
import org.springframework.web.filter.ShallowEtagHeaderFilter;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
@Configuration
public class WebConfig implements WebMvcConfigurer {
@Bean
public Filter shallowEtagHeaderFilter(){
return new ShallowEtagHeaderFilter();
}
@Override
public void addResourceHandlers(ResourceHandlerRegistry registry){
registry
.addResourceHandler("/static/**")
.addResourceLocations("/classpath:/static/")
.setCacheControl(CacheControl.noCache())
.setCachePeriod(3600);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment