I have a method in which i want to set response header cache-control and pragma :-
public String addUser(@Valid User user, BindingResult bindingResult) {
You can manually set headers as follows.
imports:
import org.springframework.http.HttpHeaders;
code:
public ResponseEntity> doSomething() { ... HttpHeaders respHeaders = new HttpHeaders(); respHeaders.add("Pragma", "no-cache"); respHeaders.add("Cache-Control","no-cache,no-store,must-revalidate"); return new ResponseEntity>(respHeaders, HttpStatus.OK); }