From 381a1b794f9c73659f66fb223cb6db20b41111c6 Mon Sep 17 00:00:00 2001 From: kric_jspark Date: Mon, 3 Aug 2026 15:45:40 +0900 Subject: [PATCH] =?UTF-8?q?260803=5F02=5FENH:=20=EB=B8=8C=EB=9D=BC?= =?UTF-8?q?=EC=9A=B0=EC=A0=80=20=EC=BA=90=EC=8B=B1=207=EC=9D=BC=EB=A1=9C?= =?UTF-8?q?=20=EB=B3=80=EA=B2=BD=20=EB=B0=8F=20=EC=84=A4=EC=A0=95=20yml?= =?UTF-8?q?=EB=A1=9C=20=EC=9D=B4=EB=8F=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 2 ++ .../kri/shorturl/controller/QRCodeController.java | 14 +++++++++++--- src/main/resources/application.yaml | 6 ++++++ 3 files changed, 19 insertions(+), 3 deletions(-) diff --git a/.gitignore b/.gitignore index c2065bc..3f8461a 100644 --- a/.gitignore +++ b/.gitignore @@ -35,3 +35,5 @@ out/ ### VS Code ### .vscode/ + +/logs \ No newline at end of file diff --git a/src/main/java/com/kri/shorturl/controller/QRCodeController.java b/src/main/java/com/kri/shorturl/controller/QRCodeController.java index 7e43520..59e55e7 100644 --- a/src/main/java/com/kri/shorturl/controller/QRCodeController.java +++ b/src/main/java/com/kri/shorturl/controller/QRCodeController.java @@ -3,7 +3,7 @@ package com.kri.shorturl.controller; import com.kri.shorturl.service.QRCodeService; import io.swagger.v3.oas.annotations.tags.Tag; import java.time.Duration; -import lombok.RequiredArgsConstructor; +import org.springframework.beans.factory.annotation.Value; import org.springframework.http.CacheControl; import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; @@ -14,11 +14,19 @@ import org.springframework.web.bind.annotation.RestController; @RestController @RequestMapping("/api/v1/qr") -@RequiredArgsConstructor @Tag(name = "QRCode", description = "QR Code API") public class QRCodeController { private final QRCodeService qrCodeService; + private final Duration cacheMaxAge; + + public QRCodeController( + QRCodeService qrCodeService, + @Value("${kri.qr.cache-max-age:1d}") Duration cacheMaxAge + ) { + this.qrCodeService = qrCodeService; + this.cacheMaxAge = cacheMaxAge; + } @GetMapping(value = "/{encodedUrl}", produces = MediaType.IMAGE_PNG_VALUE) public ResponseEntity getQrCode(@PathVariable String encodedUrl) { @@ -26,7 +34,7 @@ public class QRCodeController { return ResponseEntity.ok() .contentType(MediaType.IMAGE_PNG) - .cacheControl(CacheControl.maxAge(Duration.ofDays(1)).cachePublic()) + .cacheControl(CacheControl.maxAge(cacheMaxAge).cachePublic()) .body(png); } } diff --git a/src/main/resources/application.yaml b/src/main/resources/application.yaml index 6abb20a..210feb2 100644 --- a/src/main/resources/application.yaml +++ b/src/main/resources/application.yaml @@ -65,6 +65,12 @@ kri: qr: max-url-bytes: 2048 + cache-max-age: 7d + #cache-max-age: 500ms # 밀리초 + #cache-max-age: 30s # 초 + #cache-max-age: 10m # 분 + #cache-max-age: 12h # 시간 + #cache-max-age: 1d # 일 web: