I am not so good in Java + Spring, but I'd like to add Cache-Control header to my ResponseEntity.
@RequestMapping(value = "/data/{id}", method = GET")
public ResponseEntity<String> getData(@PathVariable("id") String id) {
try {
...
HttpHeaders headers = new HttpHeaders();
headers.setCacheControl("max-age=600, public");
return new ResponseEntity<String>(body, headers, HttpStatus.OK);
}
}
I added two lines of code for HttpHeaders and now I get two Cache-Control headers in my response:
one with public and another with private. why?