From 5180860a37870892a3c64ae7e9bf8d72f140fdb5 Mon Sep 17 00:00:00 2001 From: kssumin <201566@jnu.ac.kr> Date: Sun, 3 Mar 2024 16:19:49 +0900 Subject: [PATCH 1/2] =?UTF-8?q?feat=20:=20cacheControl=EC=9D=84=20?= =?UTF-8?q?=ED=86=B5=ED=95=B4=20cache=EB=A5=BC=20=EC=A7=80=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../eeos/config/CacheWebConfig.java | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 BE/eeos/src/main/java/com/blackcompany/eeos/config/CacheWebConfig.java diff --git a/BE/eeos/src/main/java/com/blackcompany/eeos/config/CacheWebConfig.java b/BE/eeos/src/main/java/com/blackcompany/eeos/config/CacheWebConfig.java new file mode 100644 index 00000000..a76662bc --- /dev/null +++ b/BE/eeos/src/main/java/com/blackcompany/eeos/config/CacheWebConfig.java @@ -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); + } +} From d94afc2aedc6d5531f2fac706543ca4d1581d24f Mon Sep 17 00:00:00 2001 From: kssumin <201566@jnu.ac.kr> Date: Sun, 3 Mar 2024 17:51:52 +0900 Subject: [PATCH 2/2] =?UTF-8?q?feat=20:=20ETag=20=EC=A0=81=EC=9A=A9?= =?UTF-8?q?=ED=95=98=EC=97=AC=20=EB=8D=B0=EC=9D=B4=ED=84=B0=EC=9D=98=20?= =?UTF-8?q?=EB=B3=80=EA=B2=BD=20=EC=9C=A0=EB=AC=B4=20=ED=99=95=EC=9D=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../blackcompany/eeos/config/EtagConfig.java | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 BE/eeos/src/main/java/com/blackcompany/eeos/config/EtagConfig.java diff --git a/BE/eeos/src/main/java/com/blackcompany/eeos/config/EtagConfig.java b/BE/eeos/src/main/java/com/blackcompany/eeos/config/EtagConfig.java new file mode 100644 index 00000000..594d3761 --- /dev/null +++ b/BE/eeos/src/main/java/com/blackcompany/eeos/config/EtagConfig.java @@ -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() { + FilterRegistrationBean filterRegistrationBean = + new FilterRegistrationBean<>(new ShallowEtagHeaderFilter()); + filterRegistrationBean.addUrlPatterns("/api/*"); + + return filterRegistrationBean; + } +}