I want to set the Cache-Control and ETag headers correctly in my responses. To do that I have disabled request caching through spring security configuration:
httpSecurity.headers().cacheControl().disable();
Then when returning the response:
ResponseEntity.ok()
.header("Cache-Control", "max-age=60")
.header("ETag", "my-tag")
.build()
It seems to work in the sense that the default spring security cache-control headers are not returned (by default I think they return "no-cache, no-store, max-age=0, must-revalidate") and my headers are present in the response. However there is also something else there:
Cache-Control: private
Expires: Thu, 01 Jan 1970 00:00:00 GMT
ETag: "0.42.1-20181213080300000"
Cache-Control: max-age=60
...other headers
The lower cache headers are mine but the top ones are unwanted. They seem to come from org.apache.catalina.authenticator.AuthenticatorBase
which seems to be part of the embedded Tomcat being used. I have been unable to find a way to access and modify the configuration of this particular class.
Please advise on how to get rid of the unwanted headers.
I am on Spring boot 1.5.18.RELEASE