-
Notifications
You must be signed in to change notification settings - Fork 10k
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
[Blazor] Consume fingerprinted assets in MVC and Blazor #56045
[Blazor] Consume fingerprinted assets in MVC and Blazor #56045
Conversation
2f69855
to
4a66520
Compare
afef78d
to
ec82e49
Compare
src/Components/Endpoints/src/Builder/RazorComponentEndpointFactory.cs
Outdated
Show resolved
Hide resolved
src/Components/Endpoints/src/Builder/ResourceCollectionConvention.cs
Outdated
Show resolved
Hide resolved
src/Components/Endpoints/src/Builder/ResourceCollectionUrlEndpoint.cs
Outdated
Show resolved
Hide resolved
849e896
to
456ee28
Compare
src/Components/test/E2ETest/Infrastructure/ServerFixtures/WebHostServerFixture.cs
Outdated
Show resolved
Hide resolved
src/Mvc/Mvc.Core/src/Builder/ControllerEndpointRouteBuilderExtensions.cs
Outdated
Show resolved
Hide resolved
...eatures/src/Builder/ControllerActionEndpointConventionBuilderResourceCollectionExtensions.cs
Outdated
Show resolved
Hide resolved
Out of interest (and since this ticket is somewhat related to hot reload) is any work being done in .Net 9 to make hot reload work reliably for anything other than the most simple projects? If there's an open issue, I'd really like to track it. We have significant problems with the reliability of hot reload in both VS and Rider, on any platform, once a hosted blazor server project gets past anything larger than a couple of trivial pages/components. |
@Webreaper this work is orthogonal to hot reload. If you have concrete issues, it's best if you file issues for them and let us triage them. If there are already issues, then we'll dupe against those. With that said, the best way for us to resolve hot reload issues is if you include repro projects and detailed steps on how to trigger the concrete problems that you find. Without that, it's really hard for us to act on particular issues. |
Thanks. The problem is that with hot reload, because it requires a substantially large and complex project to break it, a small repro is challenging. I can't post my enterprise blazor platform.... But I'll see what I can do and raise a separate issue. Thanks! |
Fixes #56076
Overview
Fingerprinting endpoints are defined as part of the build process. The fingerprinted endpoints contain a property "fingerprint" with the fingerprint for the file content.
These endpoints end up mapped as StaticAsset endpoints and include cache headers to ensure that the content is cached for a long time.
The StaticAssets routerware exposes an IReadOnlyList to consumers. Each static asset descriptor represents an addressable resource and includes the route, the response headers, a set of properties that other layers can use to identify concrete assets, and a list of selectors, used to discriminate between resources mapped to the same path.
A
StaticAssetDescriptor
represents the "physical" representation of the file at the HTTP level.The information from the descriptors is exposed to Components via the ResourceAssetCollection. This concept lives in Components and provides additional information about the resources in the app that can be used by components to obtain content specific URLs and to read additional properties from assets, like their integrity value, which can then be used to apply things like CSP or subresource integrity.
For scenarios see the companion issue #56076 and this commit that focuses on the template updates.
Key design points
Exposing the asset information to components
This could have been done in three ways:
I chose to expose this through the render handle directly for a couple of motives:
Why I avoided a cascading value:
Why I avoided a scoped service:
How webassembly consumes fingerprinted assets:
Hot reload
no-cache
every asset/endpoint) to ensure that the browser always tries to retrieve up to date content.Integrations