Skip to content

Commit

Permalink
Merge pull request #302 from kssumin/main
Browse files Browse the repository at this point in the history
[BE/FEAT]캐시를 적용한다.
  • Loading branch information
kssumin authored Mar 3, 2024
2 parents 6d95c06 + 6f932fe commit 2464338
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package com.blackcompany.eeos.config;

import java.util.concurrent.TimeUnit;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.CacheControl;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
import org.springframework.web.servlet.mvc.WebContentInterceptor;

@Configuration
public class CacheWebConfig implements WebMvcConfigurer {

@Override
public void addInterceptors(final InterceptorRegistry registry) {
CacheControl cacheControl = CacheControl.maxAge(60, TimeUnit.SECONDS);

WebContentInterceptor interceptor = new WebContentInterceptor();
interceptor.addCacheMapping(cacheControl, "/api/**");

registry.addInterceptor(interceptor);
}
}
18 changes: 18 additions & 0 deletions BE/eeos/src/main/java/com/blackcompany/eeos/config/EtagConfig.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package com.blackcompany.eeos.config;

import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.filter.ShallowEtagHeaderFilter;

@Configuration
public class EtagConfig {
@Bean
public FilterRegistrationBean<ShallowEtagHeaderFilter> shallowEtagHeaderFilter() {
FilterRegistrationBean<ShallowEtagHeaderFilter> filterRegistrationBean =
new FilterRegistrationBean<>(new ShallowEtagHeaderFilter());
filterRegistrationBean.addUrlPatterns("/api/*");

return filterRegistrationBean;
}
}

0 comments on commit 2464338

Please sign in to comment.