-
Notifications
You must be signed in to change notification settings - Fork 1.2k
[Static Web Assets] Fix compressed endpoint headers #41511
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
[Static Web Assets] Fix compressed endpoint headers #41511
Conversation
else if (!string.IsNullOrEmpty(part.Value)) | ||
{ | ||
// Token was embedded, so add it to the dictionary. | ||
dictionary[part.Name] = part.Value; |
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.
When the token was embedded in the expression (for example, file#[.{fingerprint=value}].ext
we weren't adding it to the tokens returned, so it wasn't being added as a property and we weren't setting the caching headers correctly because of that.
|
||
var compressedAssets = assetsById.Values.Where(a => a.AssetTraitName == "Content-Encoding").ToList(); | ||
var updatedEndpoints = new List<StaticWebAssetEndpoint>(); | ||
var updatedEndpoints = new HashSet<StaticWebAssetEndpoint>(StaticWebAssetEndpoint.RouteAndAssetComparer); |
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.
The combination of route + asset file is unique, when we have fingerprinting expressions more than one endpoint is associated with a given compressed asset, so we need to make sure we don't add it multiple times.
Using a HashSet is simpler and better than using a list, also, in this case we need to avoid comparing using the headers and properties because those will be different.
if (!IsCompatible(compressedEndpoint, relatedEndpointCandidate)) | ||
{ | ||
continue; | ||
} |
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.
We were copying the related endpoint and applying a selector + the compressed endpoint properties. That caused for example that we created a fingerprinted endpoint using a non-fingerprinted compressed endpoint.
To address that, we check that both endpoints have or don't have fingerprint and in case of having it, they match.
This way the fingerprinted endpoint we create for content-negotiation has the same headers as the fingerprinted compressed endpoint.
be84436
to
6c4f09e
Compare
6c4f09e
to
9975c20
Compare
Uh oh!
There was an error while loading. Please reload this page.