-
Notifications
You must be signed in to change notification settings - Fork 10.4k
Description
Split from #2458 (comment)
Background:
Response compression is disabled by default for HTTPS requests due to BEAST and CRIME attacks. These attacks are primarily a concern for dynamic content that the user can influence. Since this is not the case for static assets we should have some way for those assets to opt into compression. This is especially true for the StaticFiles middleware, and transitively Blazor apps.
Proposal:
@DamianEdwards: I think the eventual fix here would be to introduce a new request feature that the static file middleware can set when serving files that indicates the response is from static content, thus allowing the compression middleware to safely compress responses only when the feature indicates it was static in nature. Of course it's still possible for another middleware in-between to change the content and introduce issues again. If we care enough about that we could have the feature actually poison the response headers and body (e.g. via wrapping) such that they can't be modified. Also, technically it isn't about what's static but what contains user manipulable content, so the feature should likely be built around that premise instead, allowing any response (including dynamic responses from things like MVC actions) to declare that they're free from user manipulation and thus safe to compress over HTTPS.
Another approach we can take is to use endpoint metadata (if StaticFiles is going to be converted).