Add cache settings for simple file.

This commit is contained in:
Christian P. MOMON 2013-10-03 13:16:30 +02:00
parent 3d9a78efdc
commit 7f1e297a3a

View file

@ -45,6 +45,7 @@ public class SimpleServletDispatcher extends HttpServlet
// static final protected Pattern LONG_REWRITED_URL_PARAMETERS = // static final protected Pattern LONG_REWRITED_URL_PARAMETERS =
// Pattern.compile("^.+-/(.)+*$"); // Pattern.compile("^.+-/(.)+*$");
static final private Pattern REWRITE_PARAMETER = Pattern.compile("[^%\\w\\d]"); static final private Pattern REWRITE_PARAMETER = Pattern.compile("[^%\\w\\d]");
static final public int CACHE_AGE = 60 * 60;
private String webclassesRootPath; private String webclassesRootPath;
@ -482,6 +483,10 @@ public class SimpleServletDispatcher extends HttpServlet
contentDispositionToken = "inline"; contentDispositionToken = "inline";
} }
response.setHeader("Content-Disposition", contentDispositionToken + "; filename=\"" + file.getName() + "\""); 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(); response.flushBuffer();
ServletOutputStream out = response.getOutputStream(); ServletOutputStream out = response.getOutputStream();