260803_02_ENH: 브라우저 캐싱 7일로 변경 및 설정 yml로 이동
This commit is contained in:
2
.gitignore
vendored
2
.gitignore
vendored
@@ -35,3 +35,5 @@ out/
|
|||||||
|
|
||||||
### VS Code ###
|
### VS Code ###
|
||||||
.vscode/
|
.vscode/
|
||||||
|
|
||||||
|
/logs
|
||||||
@@ -3,7 +3,7 @@ package com.kri.shorturl.controller;
|
|||||||
import com.kri.shorturl.service.QRCodeService;
|
import com.kri.shorturl.service.QRCodeService;
|
||||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
import java.time.Duration;
|
import java.time.Duration;
|
||||||
import lombok.RequiredArgsConstructor;
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.http.CacheControl;
|
import org.springframework.http.CacheControl;
|
||||||
import org.springframework.http.MediaType;
|
import org.springframework.http.MediaType;
|
||||||
import org.springframework.http.ResponseEntity;
|
import org.springframework.http.ResponseEntity;
|
||||||
@@ -14,11 +14,19 @@ import org.springframework.web.bind.annotation.RestController;
|
|||||||
|
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/api/v1/qr")
|
@RequestMapping("/api/v1/qr")
|
||||||
@RequiredArgsConstructor
|
|
||||||
@Tag(name = "QRCode", description = "QR Code API")
|
@Tag(name = "QRCode", description = "QR Code API")
|
||||||
public class QRCodeController {
|
public class QRCodeController {
|
||||||
|
|
||||||
private final QRCodeService qrCodeService;
|
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)
|
@GetMapping(value = "/{encodedUrl}", produces = MediaType.IMAGE_PNG_VALUE)
|
||||||
public ResponseEntity<byte[]> getQrCode(@PathVariable String encodedUrl) {
|
public ResponseEntity<byte[]> getQrCode(@PathVariable String encodedUrl) {
|
||||||
@@ -26,7 +34,7 @@ public class QRCodeController {
|
|||||||
|
|
||||||
return ResponseEntity.ok()
|
return ResponseEntity.ok()
|
||||||
.contentType(MediaType.IMAGE_PNG)
|
.contentType(MediaType.IMAGE_PNG)
|
||||||
.cacheControl(CacheControl.maxAge(Duration.ofDays(1)).cachePublic())
|
.cacheControl(CacheControl.maxAge(cacheMaxAge).cachePublic())
|
||||||
.body(png);
|
.body(png);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -65,6 +65,12 @@ kri:
|
|||||||
|
|
||||||
qr:
|
qr:
|
||||||
max-url-bytes: 2048
|
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:
|
web:
|
||||||
|
|||||||
Reference in New Issue
Block a user