-
Notifications
You must be signed in to change notification settings - Fork 1.1k
[Static Web Assets] Remove weak ETag generation for compressed assets #50291
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
Co-authored-by: javiercn <[email protected]>
Co-authored-by: javiercn <[email protected]>
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.
Undo changes to this file.
test/Microsoft.NET.Sdk.StaticWebAssets.Tests/StaticWebAssets/ApplyCompressionNegotiationTest.cs
Outdated
Show resolved
Hide resolved
…pplyCompressionNegotiationTest.cs
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.
Pull Request Overview
This PR removes the generation of weak ETags for compressed static web assets to eliminate problematic dual ETag responses. Previously, compressed assets received both their own strong ETag and a weak ETag derived from the original asset, which could cause HTTP caching issues.
- Removes weak ETag generation logic from the compression negotiation task
- Updates test expectations across unit and integration tests to match the new behavior
- Preserves strong ETags based on compressed content for proper cache validation
Reviewed Changes
Copilot reviewed 11 out of 73 changed files in this pull request and generated no comments.
File | Description |
---|---|
test/Microsoft.NET.Sdk.BlazorWebAssembly.Tests/StaticWebAssetsBaselines/StaticWebAssets_Build_Hosted_Works.Build.staticwebassets.json | Removes duplicate ETag entries from compressed asset baseline test file |
test/Microsoft.NET.Sdk.BlazorWebAssembly.Tests/StaticWebAssetsBaselines/StaticWebAssets_BuildMinimal_Works.Build.staticwebassets.json | Removes duplicate ETag entries from minimal build baseline test file |
test/Microsoft.NET.Sdk.BlazorWebAssembly.Tests/StaticWebAssetsBaselines/StaticWebAssets_BackCompatibilityPublish_Hosted_Works.Publish.staticwebassets.json | Removes duplicate ETag entries from back compatibility publish baseline test file |
test/Microsoft.NET.Sdk.BlazorWebAssembly.Tests/StaticWebAssetsBaselines/Publish_DoesNotGenerateManifestJson_IncludesJSModulesOnBlazorBootJsonManifest.Publish.staticwebassets.json | Removes duplicate ETag entries from publish baseline test file |
You can also share your feedback on Copilot code review for a chance to win a $100 gift card. Take the survey.
This PR fixes an issue where compressed static web assets were receiving both strong and weak ETags on the same HTTP response, which causes problems in some situations.
Problem
The
ApplyCompressionNegotiation
task was adding weak ETags (e.g.,W/"original-etag"
) to compressed assets in addition to their own strong ETags (e.g.,"compressed-gzip-etag"
). This resulted in responses with multiple ETags:Having both strong and weak ETags on the same response can cause issues with HTTP caching and conditional requests in certain scenarios.
Solution
ApplyCompressionNegotiation.cs
(lines 374-389) that was generating weak ETags from the original asset's ETagResult
Compressed assets now have only their own strong ETag based on the compressed content:
This eliminates the problematic dual ETag scenario while preserving all caching functionality. The strong ETag from the compressed content is sufficient for proper HTTP cache validation.
Files Changed
src/StaticWebAssetsSdk/Tasks/ApplyCompressionNegotiation.cs
- Removed weak ETag generation logictest/Microsoft.NET.Sdk.StaticWebAssets.Tests/StaticWebAssets/ApplyCompressionNegotiationTest.cs
- Updated test expectationstest/Microsoft.NET.Sdk.StaticWebAssets.Tests/StaticWebAssetsCompressionIntegrationTest.cs
- Removed weak ETag assertionsFixes #50290.
💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.