Skip to content

[release/10.0] Add cache setting to asset definition, use "force-cache" for fingerprinted assets#122442

Merged
lewing merged 22 commits intodotnet:release/10.0from
maraf:AssetCacheBackport10
Dec 11, 2025
Merged

[release/10.0] Add cache setting to asset definition, use "force-cache" for fingerprinted assets#122442
lewing merged 22 commits intodotnet:release/10.0from
maraf:AssetCacheBackport10

Conversation

@maraf
Copy link
Member

@maraf maraf commented Dec 11, 2025

Backport of #122101 to release/10.0 to fix dotnet/aspnetcore#64009

Customer Impact

  • Customer reported
  • Found internally

The issue significantly effects startup time of every WebAssembly based application.

Regression

  • Yes
  • No

Caused by #114901

Testing

Manual testing of Blazor WebAssembly standalone, Blazor Web with WebAssembly & Auto interactivity, with Chromium-based, Firefox and Safari.
Automated test.

Risk

Low. We are changing both built-time generator and runtime part reading the values. Thanks to fingerprinting there isn't a room for some staleness of one part. The change is scoped and in case it won't work in some scenario, the workaround is still possible.

@maraf maraf added this to the 10.0.x milestone Dec 11, 2025
@maraf maraf self-assigned this Dec 11, 2025
@maraf maraf added arch-wasm WebAssembly architecture area-Build-mono os-browser Browser variant of arch-wasm labels Dec 11, 2025
@dotnet-policy-service
Copy link
Contributor

Tagging subscribers to 'arch-wasm': @lewing, @pavelsavara
See info in area-owners.md if you want to be subscribed.

@maraf maraf marked this pull request as ready for review December 11, 2025 11:37
@maraf maraf requested a review from ilonatommy as a code owner December 11, 2025 11:37
Copilot AI review requested due to automatic review settings December 11, 2025 11:37
@maraf maraf added the Servicing-consider Issue for next servicing release review label Dec 11, 2025
@maraf maraf requested a review from a team December 11, 2025 11:37
Copy link
Contributor

Copilot AI left a 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 backports a performance improvement for WebAssembly applications by adding cache control settings to asset definitions. The change uses "force-cache" for fingerprinted assets to enable browser-level caching, significantly improving startup performance on subsequent loads.

Key changes:

  • Added cache property to all fingerprinted asset types (WasmAsset, AssemblyAsset, PdbAsset, SymbolsAsset, VfsAsset, IcuAsset, GeneralAsset)
  • Implemented logic to set cache to "force-cache" for fingerprinted assets and null for non-fingerprinted assets
  • Updated both C# (build-time) and TypeScript (runtime) code to handle the new cache property

Reviewed changes

Copilot reviewed 27 out of 29 changed files in this pull request and generated no comments.

Show a summary per file
File Description
src/tasks/Microsoft.NET.Sdk.WebAssembly.Pack.Tasks/BootJsonData.cs Added cache property to asset classes (WasmAsset, GeneralAsset, VfsAsset, SymbolsAsset) for storing cache control settings
src/tasks/Microsoft.NET.Sdk.WebAssembly.Pack.Tasks/BootJsonBuilderHelper.cs Implemented GetCacheControl helper and updated asset mapping to set cache property based on fingerprinting status
src/mono/browser/runtime/types/internal.ts Updated AssetEntryInternal to use cache?: RequestCache instead of noCache?: boolean
src/mono/browser/runtime/types/index.ts Added cache?: RequestCache property to TypeScript asset type definitions
src/mono/browser/runtime/loader/assets.ts Updated fetch logic to use asset.cache when specified, maintaining backward compatibility
src/mono/browser/runtime/dotnet.d.ts Updated public TypeScript definitions to match internal types
src/mono/wasm/Wasm.Build.Tests/Blazor/AssetCachingTests.cs Added comprehensive test verifying cache behavior with and without fingerprinting
src/mono/wasm/Wasm.Build.Tests/BrowserStructures/TestAsset.cs Registered new BlazorWebWasm test asset
src/mono/wasm/Wasm.Build.Tests/BrowserStructures/RunOptions.cs Fixed whitespace formatting
src/mono/wasm/Wasm.Build.Tests/Templates/WasmTemplateTestsBase.cs Refactored to extract BrowserRun method and added projectDir parameter support
src/mono/wasm/Wasm.Build.Tests/WasmSdkBasedProjectProvider.cs Added optional projectDir parameter to GetBuildPaths
src/mono/wasm/Wasm.Build.Tests/Common/ToolCommand.cs Improved error handling for process start failures
src/mono/wasm/testassets/BlazorWebWasm/* Added complete BlazorWebWasm test project for integration testing
eng/testing/scenarios/BuildWasmAppsJobsList.txt Added AssetCachingTests to test job list

@maraf
Copy link
Member Author

maraf commented Dec 11, 2025

@maraf maraf changed the title [backport release/10.0] Add cache setting to asset definition, use "force-cache" for fingerprinted assets [release/10.0] Add cache setting to asset definition, use "force-cache" for fingerprinted assets Dec 11, 2025
@rbhanda rbhanda modified the milestones: 10.0.x, 10.0.3 Dec 11, 2025
@rbhanda rbhanda added Servicing-approved Approved for servicing release and removed Servicing-consider Issue for next servicing release review labels Dec 11, 2025
@lewing lewing merged commit 266ead9 into dotnet:release/10.0 Dec 11, 2025
53 of 65 checks passed
@maraf maraf deleted the AssetCacheBackport10 branch December 11, 2025 17:15
@rbhanda rbhanda modified the milestones: 10.0.3, 10.0.2 Dec 11, 2025
@github-actions github-actions bot locked and limited conversation to collaborators Jan 11, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

arch-wasm WebAssembly architecture area-Build-mono os-browser Browser variant of arch-wasm Servicing-approved Approved for servicing release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants