Closed rasander closed 5 months ago
Thanks for reporting! Would you like to send a Pull Request to address this issue? Remember to add unit tests.
"Accept-Encoding" is always added to Vary for both compressable and non-compressable content-types. This should only be added if content-type is compressable.
@rasander Do you have a link to a spec that states this?
@rasander Could you confirm if my understanding is correct?
response.headers['content-encoding']
is defined (unless the value is identity
, then the header vary
should contain accept-encoding
Open question:
if only one accept-encoding
in request header, should vary
header be set in response?
I have provided a PR, but I'm not so certain, if the changes in tests are all valid. @mcollina @Fdawgs
"Accept-Encoding" is always added to Vary for both compressable and non-compressable content-types. This should only be added if content-type is compressable.
@rasander Do you have a link to a spec that states this?
https://www.fastly.com/blog/best-practices-using-vary-header See the section How to Use Vary to Solve Problems
Prerequisites
Fastify version
4.25.2
Plugin version
6.5.0
Node.js version
20.x
Operating system
Linux
Operating system version (i.e. 20.04, 11.3, 10)
Mac OS X and Linux Ubuntu
Description
"Accept-Encoding" is always added to Vary for both compressable and non-compressable content-types. This should only be added if content-type is compressable.
This means, that caching is not working properly in nginx or CDN, because some caching applications (in my case Akamai CDN), will only cache if Content-Encoding is matching Accept-Encoding (in case Accept-Encoding is included in Vary). For non-compressable content-types these will not match.
Steps to Reproduce
Expected Behavior