Skip to content

Commit

Permalink
Merge pull request #1331 from scireum/ili/OX-10618
Browse files Browse the repository at this point in the history
Do not cache help pages, caches help assets longer
  • Loading branch information
idlira authored Nov 29, 2023
2 parents 605a91f + 8fafcd7 commit 1f69bc4
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/main/java/sirius/web/dispatch/HelpDispatcher.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
import sirius.web.security.UserContext;

import java.io.IOException;
import java.time.Duration;
import java.util.List;
import java.util.regex.Pattern;

Expand All @@ -54,6 +55,9 @@ public class HelpDispatcher implements WebDispatcher {
@ConfigValue("help.languages")
private List<String> helpSystemLanguageDirectories;

@ConfigValue("http.response.defaultStaticAssetTTL")
private static Duration defaultStaticAssetTTL;

@Part
private Resources resources;

Expand Down Expand Up @@ -114,14 +118,16 @@ private DispatchDecision serveAsset(WebContext ctx, String uri) throws IOExcepti
return DispatchDecision.CONTINUE;
}

ctx.respondWith().resource(asset.getUrl().openConnection());
ctx.respondWith()
.cachedForSeconds((int) defaultStaticAssetTTL.getSeconds())
.resource(asset.getUrl().openConnection());
return DispatchDecision.DONE;
}

private DispatchDecision serveTopic(WebContext ctx, String uri) {
Template template = resolveTemplate(uri);
if (template != null) {
ctx.respondWith().cached().template(HttpResponseStatus.OK, template);
ctx.respondWith().notCached().template(HttpResponseStatus.OK, template);
return DispatchDecision.DONE;
}

Expand Down

0 comments on commit 1f69bc4

Please sign in to comment.