-
-
Notifications
You must be signed in to change notification settings - Fork 774
fix(static): add vary: accept-encoding for assets with compressed version
#3443
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
fb0e772 to
cb2599c
Compare
|
@pi0 I've updated the commit to fix the failing tests. |
vary: accept-encoding for compressed assets
|
@pi0 is attempting to deploy a commit to the Nitro Team on Vercel. A member of the Team first needs to authorize it. |
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the β¨ Finishing touchesπ§ͺ Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, this got delayed and thanks for adding tests!
I have locally investigated. We can reduce runtime overhead (of iteration and resolving for all static assets) by instead, flagging static assets that have a compressed variant with encoding: null build-time and then add vary header for them. It will cover tests.
vary: accept-encoding for compressed assetsvary: accept-encoding for assets with compressed version
commit: |
π Linked issue
#3077
β Type of change
π Description
The build process produces compressed public assets based on nitro option 'compressPublicAssets' if those assets are present then it means the response may 'Vary' based on Accept-Encoding request header.
Currently the 'Vary' based on Accept-Encoding request header is included only if the Accept-Encoding request header exists. This introduces a problem that the Vary header can get omitted if the client sends a request without Accept-Encoding header. This would cause the server to respond with a uncompressed file that would then be cached in shared caches and served to everyone.
Shifting the logic so that the header is always sent if the server is optionally configured to return uncompressed, gz or br public assets removes the possibility for a client to poison the cache for all.
Resolves #3077
π Checklist