Replies: 1 comment 6 replies
-
That would make sense if all the compression criteria were met except for the Accept-Encoding. You wouldn't want to add Vary to a response that wouldn't otherwise be compressible. With the current abreactions it might be tricky to make that granular distinction. Are you willing to do some experimenting? |
Beta Was this translation helpful? Give feedback.
6 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I recently ran into a "problem" when I put Response Caching middleware and Response Compression middleware together. The problem is that ASP.NET Response Caching middleware return uncompressed cached response despite of Accept-Encoding request header. While this does not violate HTTP protocol, as uncompressed response is valid for any Accept-Endoing values, it is sub-optimal.
My setup is that, in order to get my response compressed before getting cached, I register Response Compression middleware behind Response Caching middleware. This works fine when Accept-Encoding presents for all requests.
However, when I make a request without Accept-Encoding header, my compressed cached response gets overridden by uncompressed one. All the subsequent requests will get uncompressed response no matter what.
I am not very sure whether this is a bug or not, but I think all compressible responses passing through Response Compression also warrants the Vary header even it is uncompressed. "Compressible" here means there might be some chance that the response might be compressed by some request.
Here is the documentation
While the middleware works as documented, I don't think the Vary header should be omitted for uncompressed response.
My workaround right now is that I put
Vary: Accept-Encoding
to every cachable response.Beta Was this translation helpful? Give feedback.
All reactions