GzipFilter: Add Vary header for compressible responses even when not gzipped by tsawada · Pull Request #13822 · playframework/playframework
Pull Request Checklist
- Have you read How to write the perfect pull request?
- Have you read through the contributor guidelines?
- Have you referenced any issues you're fixing using commit message keywords?
- Have you added copyright headers to new files?
- Have you checked that both Scala and Java APIs are updated?
- Have you updated the documentation for both Scala and Java sections?
- Have you added tests for any changed functionality?
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