diff --git a/backend/src/main/java/de/grimsi/gameyfin/rest/ImageController.java b/backend/src/main/java/de/grimsi/gameyfin/rest/ImageController.java index 5f30154..9d2bd79 100644 --- a/backend/src/main/java/de/grimsi/gameyfin/rest/ImageController.java +++ b/backend/src/main/java/de/grimsi/gameyfin/rest/ImageController.java @@ -3,12 +3,16 @@ package de.grimsi.gameyfin.rest; import de.grimsi.gameyfin.service.DownloadService; import lombok.RequiredArgsConstructor; import org.springframework.core.io.Resource; +import org.springframework.http.CacheControl; import org.springframework.http.MediaType; +import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; +import java.util.concurrent.TimeUnit; + /** * This controller handles functionality for images. */ @@ -20,7 +24,9 @@ public class ImageController { private final DownloadService downloadService; @GetMapping(value = "/{imageId}", produces = MediaType.IMAGE_PNG_VALUE) - public Resource getCoverImageForGame(@PathVariable String imageId) { - return downloadService.downloadImage(imageId); + public ResponseEntity getCoverImageForGame(@PathVariable String imageId) { + return ResponseEntity.ok() + .cacheControl(CacheControl.maxAge(365, TimeUnit.DAYS).cachePublic()) + .body(downloadService.downloadImage(imageId)); } }