aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2017-08-16 00:36:49 +1200
committerAnton Tananaev <anton.tananaev@gmail.com>2017-08-16 00:36:49 +1200
commitcbaf29aeb7525deb1f81426c7d4d6cd9f39f500d (patch)
tree3a042b841c14697b92bce15a8bfba535a231d6ba
parent5606c72b19568ddf50e2fa35f35e05358bb671e4 (diff)
downloadtrackermap-server-cbaf29aeb7525deb1f81426c7d4d6cd9f39f500d.tar.gz
trackermap-server-cbaf29aeb7525deb1f81426c7d4d6cd9f39f500d.tar.bz2
trackermap-server-cbaf29aeb7525deb1f81426c7d4d6cd9f39f500d.zip
Make cache control configurable
-rw-r--r--setup/default.xml1
-rw-r--r--src/org/traccar/web/WebServer.java6
2 files changed, 6 insertions, 1 deletions
diff --git a/setup/default.xml b/setup/default.xml
index ff0447652..edb3dd47d 100644
--- a/setup/default.xml
+++ b/setup/default.xml
@@ -9,6 +9,7 @@
<entry key='web.enable'>true</entry>
<entry key='web.port'>8082</entry>
<entry key='web.path'>./web</entry>
+ <entry key='web.cacheControl'>max-age=3600,public</entry>
<entry key='geocoder.enable'>true</entry>
<entry key='geocoder.type'>google</entry>
diff --git a/src/org/traccar/web/WebServer.java b/src/org/traccar/web/WebServer.java
index 83ead7ad8..9b4b566ef 100644
--- a/src/org/traccar/web/WebServer.java
+++ b/src/org/traccar/web/WebServer.java
@@ -29,6 +29,7 @@ import org.glassfish.jersey.jackson.JacksonFeature;
import org.glassfish.jersey.server.ResourceConfig;
import org.glassfish.jersey.servlet.ServletContainer;
import org.traccar.Config;
+import org.traccar.Context;
import org.traccar.api.AsyncSocketServlet;
import org.traccar.api.CorsResponseFilter;
import org.traccar.api.ObjectMapperProvider;
@@ -105,7 +106,10 @@ public class WebServer {
resourceHandler.setWelcomeFiles(new String[] {"debug.html", "index.html"});
resourceHandler.setMinMemoryMappedContentLength(-1); // avoid locking files on Windows
} else {
- resourceHandler.setCacheControl("max-age=3600,public");
+ String cache = config.getString("web.cacheControl");
+ if (cache != null && !cache.isEmpty()) {
+ resourceHandler.setCacheControl(cache);
+ }
resourceHandler.setWelcomeFiles(new String[] {"release.html", "index.html"});
}
handlers.addHandler(resourceHandler);