spring-projects / spring-projects/spring-security

Write HTTP Headers Eagerly by Default

Open
#18,840 0 comments 0 reactions 1 assignee View on GitHub

@rwinch is already working on this.

Since Mar 3, 2026.

in: web type: breaks-passivity type: enhancement
Dominant language
Java
Stars
9.6k
Forks
6.3k
Avg merge
2d 11h
Merged PRs (30d)
52

Description

Previously, it was not ideal for Spring Security to proactively set HTTP Headers because setting a header meant there was no way for the user to remove a header.

This has changed in Servlet 6.1 where the Javadoc of HttpServletResponse.setHeader(String, String) states:

Passing null as the value removes all headers with the given name.

Users could always override the default headers with a new value. Since servlet 6.1, they can now remove the header.

Spring Security should be updated to set the headers eagerly by default. Users wishing to override headers can now do so.

This does break passivity because today applications that set or adds a single cache control header ensures that Spring Security sets no cache control headers.

  • Applications cannot use addHeader if they want to override Spring Security's default headers
  • Applications must explicitly override every cache control header that they wish to change

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.