Skip to content
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 static asset delivery and fingerprinting #33010

Merged
merged 13 commits into from
Jul 9, 2024

Conversation

guardrex
Copy link
Collaborator

@guardrex guardrex commented Jul 8, 2024

Fixes #33005
Addresses #32960
Addresses #31909

I still need to go through the full doc set and add/version the hrefs for static assets. However, should I just wait until the tilde-slash (~/) feature is implemented for the compiler before doing that? I think there might be like ... mmmmm 🤔 ... 50 or so spots to update. I'd like to wait and hit them on one pass if the ~/ feature will be implemented soon.

The compiler feature won't make .NET 9. I'm versioning hrefs on this PR.


Internal previews

Toggle expand/collapse
📄 File 🔗 Preview link
aspnetcore/blazor/components/class-libraries.md Consume ASP.NET Core Razor components from a Razor class library (RCL)
aspnetcore/blazor/components/css-isolation.md ASP.NET Core Blazor CSS isolation
aspnetcore/blazor/components/integration.md Integrate ASP.NET Core Razor components into ASP.NET Core apps
aspnetcore/blazor/fundamentals/environments.md aspnetcore/blazor/fundamentals/environments
aspnetcore/blazor/fundamentals/static-files.md ASP.NET Core Blazor static files
aspnetcore/blazor/host-and-deploy/webassembly-caching/index.md ASP.NET Core Blazor WebAssembly .NET runtime and app bundle caching
aspnetcore/blazor/host-and-deploy/webassembly.md Host and deploy ASP.NET Core Blazor WebAssembly
aspnetcore/blazor/security/server/additional-scenarios.md Server-side ASP.NET Core Blazor additional security scenarios
aspnetcore/blazor/security/webassembly/additional-scenarios.md aspnetcore/blazor/security/webassembly/additional-scenarios
aspnetcore/blazor/security/webassembly/hosted-with-azure-active-directory-b2c.md Secure a hosted ASP.NET Core Blazor WebAssembly app with Azure Active Directory B2C
aspnetcore/blazor/security/webassembly/hosted-with-identity-server.md [Visual Studio](https://review.learn.microsoft.com/en-us/aspnet/core/blazor/security/webassembly/hosted-with-identity-server?branch=pr-en-us-33010)
aspnetcore/blazor/security/webassembly/hosted-with-microsoft-entra-id.md Secure a hosted ASP.NET Core Blazor WebAssembly app with Microsoft Entra ID
aspnetcore/blazor/security/webassembly/standalone-with-identity.md Secure ASP.NET Core Blazor WebAssembly with ASP.NET Core Identity

@guardrex guardrex changed the title Blazor static asset delivery and fingerprinting [HOLD, Pre6] Blazor static asset delivery and fingerprinting Jul 8, 2024
@guardrex guardrex self-assigned this Jul 8, 2024
@guardrex guardrex requested a review from javiercn July 8, 2024 17:52
@guardrex guardrex added the 9.0 .NET 9 label Jul 8, 2024
@danroth27
Copy link
Member

However, should I just wait until the tilde-slash (~/) feature is implemented for the compiler before doing that?

We don't expect the compiler feature to get implemented for .NET 9.

@guardrex
Copy link
Collaborator Author

guardrex commented Jul 8, 2024

In that case, I'll add the updates tomorrow morning well before release.

@guardrex
Copy link
Collaborator Author

guardrex commented Jul 9, 2024

@javiercn @danroth27 @mkArtakMSFT ... I'm not 100% sure if HREFs are changing for RCLs with the new static file delivery optimizations ... e.g. ...

<link href="_content/ComponentLibrary/additionalStyles.css" rel="stylesheet" />

... to ...

<link href="@Assets["_content/ComponentLibrary/additionalStyles.css"]" rel="stylesheet" />

I assume that's correct. If I don't hear back, I'll just check on this in a few hours with Pre6 release bits and make a quick set of separate updates if needed to revert this set of updates.

... and noting in passing that since the file optimizations only apply to server-side Blazor apps that things might get tricky in spots where a passing reference is made to a static file link. Not only am I versioning 9.0+ for @Assets[], I also need to leave the original non-@Assets[] HREF for standalone WASM apps ....... somehow 🤔. I'll work on it.

UPDATE: False alarm ... versioning isn't bad this time 😅. However, I'm adding a summary section on <link> href formats to the Static Files article to summarize them for devs.

@guardrex
Copy link
Collaborator Author

guardrex commented Jul 9, 2024

I'm attempting a Blazor doc-wide approach for versioning HREF link examples:

* Place a section entitled Summary of static file <link> href formats into the Static Files article. The section presents tables by release version and app type with examples.
* For our doc examples of static file <link>s ...
* Give them the static file location (path).
* Cross-link to the new section.

If that works, we won't end up in 😈 versioning hell 😈 due to permutations of app type and href format over the releases.

UPDATE: Not a problem after all. I can use article versioning. I'll leave the new summary section in the Static Files article tho. I think that's good to keep.

@javiercn
Copy link
Member

javiercn commented Jul 9, 2024

@javiercn @danroth27 @mkArtakMSFT ... I'm not 100% sure if HREFs are changing for RCLs with the new static file delivery optimizations ... e.g. ...

<link href="_content/ComponentLibrary/additionalStyles.css" rel="stylesheet" />

... to ...

<link href="@Assets["_content/ComponentLibrary/additionalStyles.css"]" rel="stylesheet" />

I assume that's correct. If I don't hear back, I'll just check on this in a few hours with Pre6 release bits and make a quick set of separate updates if needed to revert this set of updates.

... and noting in passing that since the file optimizations only apply to server-side Blazor apps that things might get tricky in spots where a passing reference is made to a static file link. Not only am I versioning 9.0+ for @Assets[], I also need to leave the original non-@Assets[] HREF for standalone WASM apps ....... somehow 🤔. I'll work on it.

About the last paragraph. This works for Server and Webassembly, the main difference is hosted vs standalone applications.

@guardrex
Copy link
Collaborator Author

guardrex commented Jul 9, 2024

the main difference is hosted vs standalone applications

Covering this with so many permutations will create versioning hell in individual articles because the articles are usually already versioning content that would have to be further versioned to support this (without Version-by-File, which isn't available) and because we're now also throwing in app type differences. I think my centralized approach will work. See if the new section entitled Summary of static file <link> href formats in the Static Files article covers it correctly.

UPDATE: No worries on this. Turns out that versioning in the articles will be fine for these updates 👍.

@guardrex guardrex merged commit 6534547 into main Jul 9, 2024
3 checks passed
@guardrex guardrex deleted the guardrex/blazor-file-delivery-90pre6 branch July 9, 2024 17:04
@guardrex guardrex changed the title [HOLD, Pre6] Blazor static asset delivery and fingerprinting Blazor static asset delivery and fingerprinting Jul 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
9.0 .NET 9
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Static asset delivery and fingerprinting
3 participants