Commit e669c2a3 authored by Matija Obreza's avatar Matija Obreza
Browse files

Friendly cache headers

- Closes #204
parent 34963593
......@@ -80,6 +80,7 @@ import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Sort;
import org.springframework.data.elasticsearch.core.facet.result.Term;
import org.springframework.data.elasticsearch.core.facet.result.TermResult;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
......@@ -829,6 +830,8 @@ public class ExplorerController extends BaseController implements InitializingBe
byte[] image = mappingService.getTile(appliedFilters, zoom, x, y);
image = changeColor(color, image);
response.setHeader(HttpHeaders.CACHE_CONTROL, "max-age=3600, s-maxage=3600, public, no-transform");
response.getOutputStream().write(image, 0, image.length);
} catch (final IOException e) {
......
......@@ -71,7 +71,7 @@ public class RepositoryDownloadController extends BaseController {
data = this.repositoryService.getFileBytes(repositoryFile.getStoragePath(), repositoryFile.getFilename());
response.setHeader(HttpHeaders.CACHE_CONTROL, "max-age=3600, s-maxage=3600, public, no-transform");
response.setHeader(HttpHeaders.CACHE_CONTROL, "max-age=86400, s-maxage=86400, public, no-transform");
response.setHeader(HttpHeaders.PRAGMA, "");
response.setDateHeader(HttpHeaders.LAST_MODIFIED, repositoryFile.getLastModifiedDate().getTime());
response.setContentType(repositoryFile.getContentType());
......
......@@ -112,7 +112,7 @@ public class WebConfiguration extends WebMvcConfigurerAdapter {
@Override
public void addResourceHandlers(final ResourceHandlerRegistry registry) {
registry.addResourceHandler("/html/**").addResourceLocations("/html/").setCacheControl(CacheControl.maxAge(42, TimeUnit.DAYS).cachePrivate());
registry.addResourceHandler("/html/**").addResourceLocations("/html/").setCacheControl(CacheControl.maxAge(1, TimeUnit.DAYS).cachePublic());
registry.addResourceHandler("/swagger-ui.html").addResourceLocations("classpath:/META-INF/resources/");
registry.addResourceHandler("/webjars/**").addResourceLocations("classpath:/META-INF/resources/webjars/");
......
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