From 7f1e297a3aeb0e96edd1a213d2890d1b9c3c4ebf Mon Sep 17 00:00:00 2001 From: "Christian P. MOMON" Date: Thu, 3 Oct 2013 13:16:30 +0200 Subject: [PATCH] Add cache settings for simple file. --- src/fr/devinsy/kiss4web/SimpleServletDispatcher.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/fr/devinsy/kiss4web/SimpleServletDispatcher.java b/src/fr/devinsy/kiss4web/SimpleServletDispatcher.java index 317e15e..18d692e 100755 --- a/src/fr/devinsy/kiss4web/SimpleServletDispatcher.java +++ b/src/fr/devinsy/kiss4web/SimpleServletDispatcher.java @@ -45,6 +45,7 @@ public class SimpleServletDispatcher extends HttpServlet // static final protected Pattern LONG_REWRITED_URL_PARAMETERS = // Pattern.compile("^.+-/(.)+*$"); static final private Pattern REWRITE_PARAMETER = Pattern.compile("[^%\\w\\d]"); + static final public int CACHE_AGE = 60 * 60; private String webclassesRootPath; @@ -482,6 +483,10 @@ public class SimpleServletDispatcher extends HttpServlet contentDispositionToken = "inline"; } response.setHeader("Content-Disposition", contentDispositionToken + "; filename=\"" + file.getName() + "\""); + + response.setDateHeader("Expires", new Date().getTime() + CACHE_AGE * 1000); + response.setHeader("Cache-Control", "max-age=" + CACHE_AGE); + response.flushBuffer(); ServletOutputStream out = response.getOutputStream();