Add cache settings for simple file.
This commit is contained in:
parent
3d9a78efdc
commit
7f1e297a3a
1 changed files with 5 additions and 0 deletions
|
@ -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();
|
||||
|
|
Loading…
Reference in a new issue