LastModifiedCachingStrategy implements CustomizationCachingStrategy { @Override public <T> ResponseEntity<T> addCacheHeaders(final T body, final Instant lastModifiedTime) { final CacheControl cacheControl = CacheControl.maxAge(MAX_AGE_DAYS, TimeUnit.HOURS).mustRevalidate(); return ResponseEntity .ok() .cacheControl(cacheControl) .lastModified(lastModifiedTime.toEpochMilli()) .body(body); }  @Override ResponseEntity<T> addCacheHeaders(final T body, final Instant lastModifiedTime);  }
@Test public void addCacheHeaders() { final Instant instant = Instant.ofEpochMilli(1495449747142L); final ResponseEntity<String> output = cachingStrategy.addCacheHeaders("cat", instant); assertThat(output.getStatusCode(), is(HttpStatus.OK)); assertThat(output.getBody(), is("cat")); final HttpHeaders headers = output.getHeaders(); assertThat(headers.get("Cache-Control"), hasItem(containsString("must-revalidate"))); assertThat(headers.get("Cache-Control"), hasItem(containsString("max-age"))); assertThat(headers.get("Last-Modified"), hasItem(containsString("Mon, 22 May 2017 10:42:27 GMT"))); }