cache control of 1 hr

This commit is contained in:
Lee 2024-04-06 18:42:52 +01:00
parent c52f9332a2
commit 1542cff64e
3 changed files with 10 additions and 1 deletions

View File

@ -5,10 +5,16 @@ import cc.fascinated.player.impl.Player;
import cc.fascinated.player.impl.Skin;
import cc.fascinated.player.impl.SkinPart;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.CacheControl;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import java.util.Map;
import java.util.Objects;
import java.util.concurrent.TimeUnit;
@RestController
@RequestMapping(value = "/")
public class PlayerController {
@ -35,9 +41,11 @@ public class PlayerController {
if (player == null) {
return null;
}
Skin skin = player.getSkin();
SkinPart head = skin.getHead();
return ResponseEntity.ok()
.cacheControl(CacheControl.maxAge(1, TimeUnit.HOURS).cachePublic())
.contentType(MediaType.IMAGE_PNG)
.body(head.getPartData());
}

View File

@ -71,6 +71,7 @@ public class SkinPart {
if (image == null) {
return null;
}
// Get the part of the image (e.g. the head)
BufferedImage partImage = image.getSubimage(this.x, this.y, this.width, this.height);
// Scale the image

View File

@ -5,7 +5,7 @@ server:
whitelabel:
enabled: false
public-url: http://localhost
public-url: http://localhost:80
mojang:
session-server: https://sessionserver.mojang.com