summaryrefslogtreecommitdiffstats
path: root/server
diff options
context:
space:
mode:
authorJuuso Valli <juuso@vaadin.com>2014-04-23 09:58:57 +0300
committerVaadin Code Review <review@vaadin.com>2014-04-23 11:06:37 +0000
commiteeb956bc645a9c2aa3714747b7889e40bcca4d5f (patch)
treef995212ac49f838c5c9cd470b66e6d777d37add9 /server
parentc9bc18cd7392b843f208445ae3e48d226f866859 (diff)
downloadvaadin-framework-eeb956bc645a9c2aa3714747b7889e40bcca4d5f.tar.gz
vaadin-framework-eeb956bc645a9c2aa3714747b7889e40bcca4d5f.zip
Add caching support for PublishedFileHandler (#13574)
Add caching support for PublishedFileHandler similar to VaadinServlet. Testing is done manually as browser caching is difficult to develop tests for. Change-Id: I314745766c9feb60758547dba77eb9e13976ce91
Diffstat (limited to 'server')
-rw-r--r--server/src/com/vaadin/server/communication/PublishedFileHandler.java9
1 files changed, 8 insertions, 1 deletions
diff --git a/server/src/com/vaadin/server/communication/PublishedFileHandler.java b/server/src/com/vaadin/server/communication/PublishedFileHandler.java
index 8fe0f7085f..d33481435e 100644
--- a/server/src/com/vaadin/server/communication/PublishedFileHandler.java
+++ b/server/src/com/vaadin/server/communication/PublishedFileHandler.java
@@ -110,7 +110,14 @@ public class PublishedFileHandler implements RequestHandler {
return true;
}
- // TODO Check and set cache headers
+ // Set caching for the published file
+ String cacheControl = "public, max-age=0, must-revalidate";
+ int resourceCacheTime = request.getService()
+ .getDeploymentConfiguration().getResourceCacheTime();
+ if (resourceCacheTime > 0) {
+ cacheControl = "max-age=" + String.valueOf(resourceCacheTime);
+ }
+ response.setHeader("Cache-Control", cacheControl);
OutputStream out = null;
try {