Skip to content

GzipFilter: Add Vary header for compressible responses even when not gzipped#13822

Open
tsawada wants to merge 2 commits intoplayframework:mainfrom
tsawada:tsawada/gzip-vary
Open

GzipFilter: Add Vary header for compressible responses even when not gzipped#13822
tsawada wants to merge 2 commits intoplayframework:mainfrom
tsawada:tsawada/gzip-vary

Conversation

@tsawada
Copy link
Copy Markdown

@tsawada tsawada commented Mar 23, 2026

Pull Request Checklist

Purpose

Previously, the Vary: Accept-Encoding header was only added when the response was actually gzipped. Now it is also added when the response is compressible but not gzipped (e.g., when the client doesn't send Accept-Encoding: gzip).
I believe this behavior better conforms to the standard, because the Vary header must indicate that the response depends on the Accept-Encoding request header, preventing downstream caches from incorrectly serving a cached uncompressed response to subsequent clients that support compression.

The diff is larger than it should be, due to indentation changes. Please let me know if you have any suggestions to minimize it.

Part of #12981

@tsawada
Copy link
Copy Markdown
Author

tsawada commented Mar 23, 2026

Now, while this change by itself is totally valid and preferable behavior, it could cause issues if someone wants to stack compression filters, as adding Vary: Accept-Encoding might suppress compression at a later stage.

Never mind. GzipFilter does compress responses that already has Vary: Accept-Encoding, so it won't cause any problem.

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.

1 participant