Skip to content

Honor qualified Cache-Control: private="field" in a shared cache (RFC9111 section 5.2.2.7) - #868

Open
arturobernalg wants to merge 1 commit into
apache:masterfrom
arturobernalg:cache-qualified-private
Open

Honor qualified Cache-Control: private="field" in a shared cache (RFC9111 section 5.2.2.7)#868
arturobernalg wants to merge 1 commit into
apache:masterfrom
arturobernalg:cache-qualified-private

Conversation

@arturobernalg

Copy link
Copy Markdown
Member

A shared cache now stores a response that carries a qualified private directive with the named header fields removed from the stored copy, instead of treating the whole response as non-cacheable, while the response returned to the caller retains those fields. The fields are removed from freshly stored entries, from entries updated by a 304 revalidation, and from the root entry of a Vary response. A bare private directive still makes the whole response non-storable by a shared cache, and multiple qualified private directives accumulate their field names.


@Test
void testParseMultiplePrivateDirectivesAccumulate() {
final Header header = new BasicHeader("Cache-Control", "private=\"X-A\", private=\"X-B\", s-maxage=3600");

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@arturobernalg What part of the spec actually defines or recommends such behavior? In my opinion only private=\"X-B\" should have an effect.

import java.util.concurrent.atomic.AtomicInteger;

import com.sun.net.httpserver.HttpExchange;
import com.sun.net.httpserver.HttpServer;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

… 9111 section 5.2.2.7)

A shared cache now stores a response that carries a qualified private directive with the
named header fields removed from the stored copy, instead of treating the whole response as
non-cacheable, while the response returned to the caller retains those fields. The fields are
removed from freshly stored entries, from entries updated by a 304 revalidation, and from the
root entry of a Vary response. A bare private directive still makes the whole response
non-storable by a shared cache, and multiple qualified private directives accumulate their
field names.
@arturobernalg
arturobernalg force-pushed the cache-qualified-private branch from e07363a to a501878 Compare August 16, 2026 17:32
@arturobernalg
arturobernalg requested a review from ok2c August 16, 2026 17:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants