Skip to content
Snippets Groups Projects
Unverified Commit c150bb38 authored by Timm Fitschen's avatar Timm Fitschen
Browse files

EHN: Cache-Control header for webui components

parent 5fc8321a
No related branches found
No related tags found
No related merge requests found
...@@ -67,3 +67,5 @@ GLOBAL_ENTITY_PERMISSIONS_FILE=./conf/core/global_entity_permissions.xml ...@@ -67,3 +67,5 @@ GLOBAL_ENTITY_PERMISSIONS_FILE=./conf/core/global_entity_permissions.xml
CERTIFICATES_KEY_PASSWORD= CERTIFICATES_KEY_PASSWORD=
CERTIFICATES_KEY_STORE_PATH= CERTIFICATES_KEY_STORE_PATH=
CERTIFICATES_KEY_STORE_PASSWORD= CERTIFICATES_KEY_STORE_PASSWORD=
WEBUI_HTTP_HEADER_CACHE_MAX_AGE=28800
\ No newline at end of file
...@@ -129,6 +129,8 @@ public class ServerProperties extends Properties { ...@@ -129,6 +129,8 @@ public class ServerProperties extends Properties {
public static final String KEY_GLOBAL_ENTITY_PERMISSIONS_FILE = "GLOBAL_ENTITY_PERMISSIONS_FILE"; public static final String KEY_GLOBAL_ENTITY_PERMISSIONS_FILE = "GLOBAL_ENTITY_PERMISSIONS_FILE";
public static final String KEY_TIMEZONE = "TIMEZONE"; public static final String KEY_TIMEZONE = "TIMEZONE";
public static final String KEY_WEBUI_HTTP_HEADER_CACHE_MAX_AGE =
"WEBUI_HTTP_HEADER_CACHE_MAX_AGE";
/** /**
* Read the config files and initialize the server properties. * Read the config files and initialize the server properties.
......
...@@ -22,8 +22,13 @@ ...@@ -22,8 +22,13 @@
*/ */
package caosdb.server.resource; package caosdb.server.resource;
import caosdb.server.CaosDBServer;
import caosdb.server.ServerProperties;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import org.restlet.data.CacheDirective;
import org.restlet.data.Header; import org.restlet.data.Header;
import org.restlet.data.MediaType; import org.restlet.data.MediaType;
import org.restlet.data.Status; import org.restlet.data.Status;
...@@ -42,7 +47,7 @@ public class Webinterface extends ServerResource { ...@@ -42,7 +47,7 @@ public class Webinterface extends ServerResource {
super.doInit(); super.doInit();
} }
private final File PUBLIC_DIRECTORY = new File("caosdb-webui/public/").getAbsoluteFile(); private static final File PUBLIC_DIRECTORY = new File("caosdb-webui/public/").getAbsoluteFile();
@Get @Get
public Representation deliver() throws IOException { public Representation deliver() throws IOException {
...@@ -86,6 +91,12 @@ public class Webinterface extends ServerResource { ...@@ -86,6 +91,12 @@ public class Webinterface extends ServerResource {
final FileRepresentation ret = new FileRepresentation(file, mt); final FileRepresentation ret = new FileRepresentation(file, mt);
List<CacheDirective> cacheDirectives = new ArrayList<>();
cacheDirectives.add(
new CacheDirective(
HeaderConstants.CACHE_MAX_AGE,
CaosDBServer.getServerProperty(ServerProperties.KEY_WEBUI_HTTP_HEADER_CACHE_MAX_AGE)));
getResponse().setCacheDirectives(cacheDirectives);
return ret; return ret;
} }
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment