Commit 02f5703e authored by Matija Obreza's avatar Matija Obreza

Tile server HTTP cache header maxAge depends on zoom level

parent 894bff48
...@@ -56,7 +56,20 @@ public class TileController { ...@@ -56,7 +56,20 @@ public class TileController {
response.setContentType(MediaType.IMAGE_PNG_VALUE); response.setContentType(MediaType.IMAGE_PNG_VALUE);
response.setContentLength(image.length); response.setContentLength(image.length);
response.setHeader(HttpHeaders.CACHE_CONTROL, "max-age=3600, s-maxage=3600, public, no-transform");
response.getOutputStream().write(image, 0, image.length); // HTTP maxAge
int maxAge;
if (zoom < 4) {
maxAge = 60 * 60 * 24; // 24 hrs
} else if (zoom < 6) {
maxAge = 60 * 60 * 2; // 2 hrs
} else if (zoom < 8) {
maxAge = 60 * 60; // 1 hr
} else {
maxAge = 60 * 5; // 5 min
}
response.setHeader(HttpHeaders.CACHE_CONTROL, "max-age=" + maxAge + ", s-maxage=" + maxAge + ", public, no-transform");
response.getOutputStream().write(image, 0, image.length);
response.getOutputStream().flush();
} }
} }
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment