preview cache header

This commit is contained in:
Patrick Haßel 2025-08-09 10:34:49 +02:00
parent 55b1af9242
commit 3dcafdd46a

View File

@ -94,6 +94,12 @@ public class PictureController {
log.warn("Tried accessing NON-EXISTENT picture: {}", request);
return new ResponseStatusException(HttpStatus.NOT_FOUND);
});
final int cacheDuration = 30 * 24 * 60 * 60;
response.setHeader("Cache-Control", "public, max-age=" + cacheDuration);
response.setDateHeader("Expires", System.currentTimeMillis() + (cacheDuration * 1000L));
response.setDateHeader("Last-Modified", System.currentTimeMillis());
try (final FileInputStream input = new FileInputStream(pictureDto.getPreviewPath().toFile())) {
response.getOutputStream().write(input.readAllBytes());
}