hinzuzufügen Ich bin nicht so gut in Java + Spring, aber ich möchte Cache-Control
Header zu meinem ResponseEntity
hinzufügen.Java + Spring Boot: Ich versuche CacheControl-Header zu 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");
return new ResponseEntity<String>(body, headers, HttpStatus.OK);
}
}
habe ich zwei Zeilen Code für HttpHeaders
und ich jetzt zwei Cache-Control
Header in meiner Antwort:
HTTP/1.1 200 OK
Server: Apache-Coyote/1.1
X-Content-Type-Options: nosniff
X-XSS-Protection: 1; mode=block
Cache-Control: no-cache, no-store, max-age=0, must-revalidate
Pragma: no-cache
Expires: 0
X-Frame-Options: DENY
Strict-Transport-Security: max-age=31536000 ; includeSubDomains
Cache-Control: max-age=600
Content-Type: application/json;charset=UTF-8
Content-Length: 18223
Date: Wed, 29 Jun 2016 21:56:57 GMT
Was habe ich falsch gemacht? Könnte mir jemand helfen?
Stehen Sie mit Frühlingssicherheit? –
Ja, meine App verfügt über eine Standardauthentifizierung für das Erreichen der REST-API. – user3742622