fix cache control, oops

This commit is contained in:
Lee 2024-04-19 20:51:33 +01:00
parent d0cfd03ad9
commit 46d4a53b11
3 changed files with 7 additions and 8 deletions

@ -28,7 +28,7 @@ public class MojangController {
CachedEndpointStatus status = mojangService.getMojangApiStatus();
return ResponseEntity.ok()
.cacheControl(CacheControl.maxAge(1, TimeUnit.MINUTES))
.cacheControl(CacheControl.maxAge(1, TimeUnit.MINUTES).cachePublic())
.eTag(String.valueOf(status.hashCode()))
.body(status);
}

@ -34,7 +34,7 @@ public class PlayerController {
CachedPlayer player = playerService.getPlayer(id);
return ResponseEntity.ok()
.cacheControl(CacheControl.maxAge(1, TimeUnit.HOURS))
.cacheControl(CacheControl.maxAge(1, TimeUnit.HOURS).cachePublic())
.eTag(String.valueOf(player.hashCode()))
.body(player);
}
@ -46,7 +46,7 @@ public class PlayerController {
CachedPlayerName player = playerService.usernameToUuid(id);
return ResponseEntity.ok()
.cacheControl(CacheControl.maxAge(6, TimeUnit.HOURS))
.cacheControl(CacheControl.maxAge(6, TimeUnit.HOURS).cachePublic())
.eTag(String.valueOf(player.hashCode()))
.body(player);
}
@ -64,7 +64,7 @@ public class PlayerController {
// Return the part image
return ResponseEntity.ok()
.cacheControl(CacheControl.maxAge(1, TimeUnit.HOURS))
.cacheControl(CacheControl.maxAge(1, TimeUnit.HOURS).cachePublic())
.contentType(MediaType.IMAGE_PNG)
.header(HttpHeaders.CONTENT_DISPOSITION, dispositionHeader.formatted(player.getUsername()))
.eTag(String.valueOf(player.hashCode()))

@ -38,7 +38,7 @@ public class ServerController {
CachedMinecraftServer server = serverService.getServer(platform, hostname);
return ResponseEntity.ok()
.cacheControl(CacheControl.maxAge(5, TimeUnit.MINUTES))
.cacheControl(CacheControl.maxAge(5, TimeUnit.MINUTES).cachePublic())
.eTag(String.valueOf(server.hashCode()))
.body(server);
}
@ -49,11 +49,10 @@ public class ServerController {
@Parameter(description = "The hostname and port of the server", example = "aetheria.cc") @PathVariable String hostname,
@Parameter(description = "Whether to download the image") @RequestParam(required = false, defaultValue = "false") boolean download) {
String dispositionHeader = download ? "attachment; filename=%s.png" : "inline; filename=%s.png";
byte[] favicon = serverService.getServerFavicon(hostname);
return ResponseEntity.ok()
.cacheControl(CacheControl.maxAge(1, TimeUnit.HOURS))
.cacheControl(CacheControl.maxAge(1, TimeUnit.HOURS).cachePublic())
.contentType(MediaType.IMAGE_PNG)
.header(HttpHeaders.CONTENT_DISPOSITION, dispositionHeader.formatted(hostname))
.eTag(String.valueOf(Arrays.hashCode(favicon)))
@ -65,7 +64,7 @@ public class ServerController {
public ResponseEntity<?> getServerBlockedStatus(
@Parameter(description = "The hostname of the server", example = "aetheria.cc") @PathVariable String hostname) {
return ResponseEntity.ok()
.cacheControl(CacheControl.maxAge(1, TimeUnit.HOURS))
.cacheControl(CacheControl.maxAge(1, TimeUnit.HOURS).cachePublic())
.eTag(String.valueOf(hostname.hashCode()))
.body(Map.of(
"blocked", mojangService.isServerBlocked(hostname)