Skip to content

Commit 19afb6e

Browse files
committed
Development: Use a more reasonable caching policy for plant uml renderings
1 parent 9499b6e commit 19afb6e

File tree

3 files changed

+7
-3
lines changed

3 files changed

+7
-3
lines changed

src/main/java/de/tum/cit/aet/artemis/programming/service/PlantUmlService.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ public byte[] generatePng(final String plantUml, final boolean useDarkTheme) thr
9191
* @return ResponseEntity PNG stream
9292
* @throws IOException if generateImage can't create the SVG
9393
*/
94-
@Cacheable(value = "plantUmlSvg", unless = "#result == null || #result.isEmpty()")
94+
@Cacheable(value = "plantUmlSvg", unless = "#result == null || #result.isEmpty() || #result.contains('Syntax Error') || #result.contains('Cannot load')")
9595
public String generateSvg(final String plantUml, final boolean useDarkTheme) throws IOException {
9696
var input = validateInputAndApplyTheme(plantUml, useDarkTheme);
9797
try (final var bos = new ByteArrayOutputStream()) {

src/main/resources/config/application-prod.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,9 @@ server:
8989
jhipster:
9090
http:
9191
cache: # Used by the CachingHttpHeadersFilter
92-
timeToLiveInDays: 1461
92+
# 7 days balances caching benefits with allowing bug fixes to propagate within a reasonable timeframe.
93+
# Longer durations (e.g., years) make it difficult to push fixes to users who have cached broken responses.
94+
timeToLiveInDays: 7
9395
security:
9496
authentication:
9597
jwt:

src/main/resources/config/application.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -382,7 +382,9 @@ jhipster:
382382
password: AN-ADMIN-PASSWORD-THAT-MUST-BE-CHANGED (FROM REGISTRY CONFIG)
383383
http:
384384
cache: # Used by the CachingHttpHeadersFilter
385-
timeToLiveInDays: 1461
385+
# 7 days balances caching benefits with allowing bug fixes to propagate within a reasonable timeframe.
386+
# Longer durations (e.g., years) make it difficult to push fixes to users who have cached broken responses.
387+
timeToLiveInDays: 7
386388
cache: # Cache configuration
387389
hazelcast: # Hazelcast distributed cache
388390
time-to-live-seconds: 3600

0 commit comments

Comments
 (0)