mirror of
https://github.com/BrenBroZAYT/gameyfin.git
synced 2026-06-13 16:40:01 +00:00
Implemented caching of static images
This commit is contained in:
@@ -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<Resource> getCoverImageForGame(@PathVariable String imageId) {
|
||||
return ResponseEntity.ok()
|
||||
.cacheControl(CacheControl.maxAge(365, TimeUnit.DAYS).cachePublic())
|
||||
.body(downloadService.downloadImage(imageId));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user