I have springboot application that enable http caching. I'm using webRequest.checkModifiedSince
as describe in here. When running my application in browser I get correct result, 200
status code on first hit and 304
on next hit. But when I run maven test to my application it seems that webRequest.checkModifiedSince
always return false.
Here is my testcase :
@Test
public void checkCache() throws Exception {
MvcResult res = this.mockMvc.perform(get("/resource/to/cache.jpg"))
.andExpect(status().isOk())
.andReturn();
String date = res.getResponse().getHeader("Last-Modified");
HttpHeaders headers = new HttpHeaders();
headers.setIfModifiedSince(Long.parseLong(date));
headers.setCacheControl("max-age=0");
this.mockMvc.perform(get("same/resource/as/above.jpg")
.headers(headers))
.andExpect(status().isNotModified());
}
Did I do something wrong here?
Aucun commentaire:
Enregistrer un commentaire