Skip to content

Commit c160acf

Browse files
authored
[browser] Remove custom cache (#114901)
1 parent e9957dc commit c160acf

File tree

11 files changed

+12
-260
lines changed

11 files changed

+12
-260
lines changed

src/mono/browser/runtime/dotnet.d.ts

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -166,14 +166,6 @@ type MonoConfig = {
166166
* debugLevel < 0 enables debugging and disables debug logging.
167167
*/
168168
debugLevel?: number;
169-
/**
170-
* Gets a value that determines whether to enable caching of the 'resources' inside a CacheStorage instance within the browser.
171-
*/
172-
cacheBootResources?: boolean;
173-
/**
174-
* Delay of the purge of the cached resources in milliseconds. Default is 10000 (10 seconds).
175-
*/
176-
cachedResourcesPurgeDelay?: number;
177169
/**
178170
* Configures use of the `integrity` directive for fetching assets
179171
*/

src/mono/browser/runtime/loader/assets.ts

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import { ENVIRONMENT_IS_NODE, ENVIRONMENT_IS_SHELL, ENVIRONMENT_IS_WEB, ENVIRONM
99
import { createPromiseController } from "./promise-controller";
1010
import { mono_log_debug, mono_log_warn } from "./logging";
1111
import { mono_exit } from "./exit";
12-
import { addCachedReponse, findCachedResponse } from "./assetsCache";
1312
import { getIcuResourceName } from "./icu";
1413
import { makeURLAbsoluteWithApplicationBase } from "./polyfills";
1514
import { mono_log_info } from "./logging";
@@ -675,7 +674,7 @@ const totalResources = new Set<string>();
675674
function download_resource (asset: AssetEntryInternal): LoadingResource {
676675
try {
677676
mono_assert(asset.resolvedUrl, "Request's resolvedUrl must be set");
678-
const fetchResponse = download_resource_with_cache(asset);
677+
const fetchResponse = fetchResource(asset);
679678
const response = { name: asset.name, url: asset.resolvedUrl, response: fetchResponse };
680679

681680
totalResources.add(asset.name!);
@@ -708,16 +707,6 @@ function download_resource (asset: AssetEntryInternal): LoadingResource {
708707
}
709708
}
710709

711-
async function download_resource_with_cache (asset: AssetEntryInternal): Promise<Response> {
712-
let response = await findCachedResponse(asset);
713-
if (!response) {
714-
response = await fetchResource(asset);
715-
addCachedReponse(asset, response);
716-
}
717-
718-
return response;
719-
}
720-
721710
function fetchResource (asset: AssetEntryInternal): Promise<Response> {
722711
// Allow developers to override how the resource is loaded
723712
let url = asset.resolvedUrl!;

src/mono/browser/runtime/loader/assetsCache.ts

Lines changed: 0 additions & 205 deletions
This file was deleted.

src/mono/browser/runtime/loader/config.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -187,10 +187,6 @@ export function normalizeConfig () {
187187
config.debugLevel = -1;
188188
}
189189

190-
if (config.cachedResourcesPurgeDelay === undefined) {
191-
config.cachedResourcesPurgeDelay = 10000;
192-
}
193-
194190
if (!config.applicationEnvironment) {
195191
config.applicationEnvironment = "Production";
196192
}

src/mono/browser/runtime/loader/globals.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ import { mono_download_assets, resolve_single_asset_path, retrieve_asset_downloa
1616
import { mono_log_error, set_thread_prefix, setup_proxy_console } from "./logging";
1717
import { invokeLibraryInitializers } from "./libraryInitializers";
1818
import { deep_merge_config, isDebuggingSupported } from "./config";
19-
import { logDownloadStatsToConsole, purgeUnusedCacheEntriesAsync } from "./assetsCache";
2019

2120
// if we are the first script loaded in the web worker, we are expected to become the sidecar
2221
if (typeof importScripts === "function" && !globalThis.onmessage) {
@@ -122,8 +121,6 @@ export function setLoaderGlobals (
122121
resolve_single_asset_path,
123122
setup_proxy_console,
124123
set_thread_prefix,
125-
logDownloadStatsToConsole,
126-
purgeUnusedCacheEntriesAsync,
127124
installUnhandledErrorHandler,
128125

129126
retrieve_asset_download,

src/mono/browser/runtime/loader/run.ts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ import { runtimeHelpers, loaderHelpers } from "./globals";
1616
import { init_globalization } from "./icu";
1717
import { setupPreloadChannelToMainThread } from "./worker";
1818
import { importLibraryInitializers, invokeLibraryInitializers } from "./libraryInitializers";
19-
import { initCacheToUseIfEnabled } from "./assetsCache";
2019

2120

2221
export class HostBuilder implements DotnetHostBuilder {
@@ -510,8 +509,6 @@ async function downloadOnly ():Promise<void> {
510509

511510
prepareAssets();
512511

513-
await initCacheToUseIfEnabled();
514-
515512
init_globalization();
516513

517514
mono_download_assets(); // intentionally not awaited
@@ -527,8 +524,6 @@ async function createEmscriptenMain (): Promise<RuntimeAPI> {
527524

528525
const promises = importModules();
529526

530-
await initCacheToUseIfEnabled();
531-
532527
streamingCompileWasm(); // intentionally not awaited
533528

534529
setTimeout(async () => {

src/mono/browser/runtime/startup.ts

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -339,14 +339,6 @@ async function onRuntimeInitializedAsync (userOnRuntimeInitialized: (module:Emsc
339339

340340
if (!runtimeHelpers.mono_wasm_runtime_is_ready) mono_wasm_runtime_ready();
341341

342-
if (loaderHelpers.config.debugLevel !== 0 && loaderHelpers.config.cacheBootResources) {
343-
loaderHelpers.logDownloadStatsToConsole();
344-
}
345-
346-
setTimeout(() => {
347-
loaderHelpers.purgeUnusedCacheEntriesAsync(); // Don't await - it's fine to run in background
348-
}, loaderHelpers.config.cachedResourcesPurgeDelay);
349-
350342
// call user code
351343
try {
352344
userOnRuntimeInitialized(Module);

src/mono/browser/runtime/types/index.ts

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -118,14 +118,6 @@ export type MonoConfig = {
118118
*/
119119
debugLevel?: number,
120120

121-
/**
122-
* Gets a value that determines whether to enable caching of the 'resources' inside a CacheStorage instance within the browser.
123-
*/
124-
cacheBootResources?: boolean,
125-
/**
126-
* Delay of the purge of the cached resources in milliseconds. Default is 10000 (10 seconds).
127-
*/
128-
cachedResourcesPurgeDelay?: number,
129121
/**
130122
* Configures use of the `integrity` directive for fetching assets
131123
*/

src/mono/browser/runtime/types/internal.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,9 +164,7 @@ export type LoaderHelpers = {
164164

165165
retrieve_asset_download(asset: AssetEntry): Promise<ArrayBuffer>;
166166
onDownloadResourceProgress?: (resourcesLoaded: number, totalResources: number) => void;
167-
logDownloadStatsToConsole: () => void;
168167
installUnhandledErrorHandler: () => void;
169-
purgeUnusedCacheEntriesAsync: () => Promise<void>;
170168

171169
loadBootResource?: LoadBootResourceCallback;
172170
invokeLibraryInitializers: (functionName: string, args: any[]) => Promise<void>,

src/mono/nuget/Microsoft.NET.Sdk.WebAssembly.Pack/build/Microsoft.NET.Sdk.WebAssembly.Browser.targets

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,6 @@ Copyright (c) .NET Foundation. All rights reserved.
6464

6565
<!-- Runtime feature defaults to trim unnecessary code -->
6666
<InvariantTimezone Condition="'$(BlazorEnableTimeZoneSupport)' == 'false'">true</InvariantTimezone>
67-
<BlazorCacheBootResources Condition="'$(BlazorCacheBootResources)' == ''">true</BlazorCacheBootResources>
6867

6968
<!-- Turn off parts of the build that do not apply to WASM projects -->
7069
<GenerateDependencyFile>false</GenerateDependencyFile>
@@ -176,6 +175,9 @@ Copyright (c) .NET Foundation. All rights reserved.
176175
<_TargetingNET90OrLater Condition="'$(TargetFrameworkIdentifier)' == '.NETCoreApp' and $([MSBuild]::VersionGreaterThanOrEquals('$(TargetFrameworkVersion)', '9.0'))">true</_TargetingNET90OrLater>
177176
<_TargetingNET100OrLater Condition="'$(TargetFrameworkIdentifier)' == '.NETCoreApp' and $([MSBuild]::VersionGreaterThanOrEquals('$(TargetFrameworkVersion)', '10.0'))">true</_TargetingNET100OrLater>
178177

178+
<_BlazorCacheBootResources>$(BlazorCacheBootResources)</_BlazorCacheBootResources>
179+
<_BlazorCacheBootResources Condition="'$(_BlazorCacheBootResources)' == '' and '$(_TargetingNET100OrLater)' != 'true'">true</_BlazorCacheBootResources>
180+
<_BlazorCacheBootResources Condition="'$(_BlazorCacheBootResources)' == ''">false</_BlazorCacheBootResources>
179181
<_BlazorEnableTimeZoneSupport>$(BlazorEnableTimeZoneSupport)</_BlazorEnableTimeZoneSupport>
180182
<_BlazorEnableTimeZoneSupport Condition="'$(_BlazorEnableTimeZoneSupport)' == ''">true</_BlazorEnableTimeZoneSupport>
181183
<_WasmInvariantGlobalization>$(InvariantGlobalization)</_WasmInvariantGlobalization>
@@ -217,6 +219,7 @@ Copyright (c) .NET Foundation. All rights reserved.
217219
<!-- Workaround for https://github.com/dotnet/sdk/issues/12114-->
218220
<PublishDir Condition="'$(AppendRuntimeIdentifierToOutputPath)' != 'true' AND '$(PublishDir)' == '$(OutputPath)$(RuntimeIdentifier)\$(PublishDirName)\'">$(OutputPath)$(PublishDirName)\</PublishDir>
219221
</PropertyGroup>
222+
<Warning Text="Custom Blazor cache has been removed and setting 'BlazorCacheBootResources' has no effect. Follow a migration path at TODO: PLACEHOLDER FOR LINK" Condition="'$(_BlazorCacheBootResources)' != 'false' and '$(_TargetingNET100OrLater)' == 'true'" />
220223
</Target>
221224

222225
<Target Name="ResolveWasmOutputs" DependsOnTargets="_ResolveWasmOutputs" />
@@ -389,7 +392,7 @@ Copyright (c) .NET Foundation. All rights reserved.
389392
DebugBuild="true"
390393
DebugLevel="$(WasmDebugLevel)"
391394
LinkerEnabled="false"
392-
CacheBootResources="$(BlazorCacheBootResources)"
395+
CacheBootResources="$(_BlazorCacheBootResources)"
393396
MergeWith="@(_WasmDotnetJsForBuild)"
394397
OutputPath="$(_WasmBuildBootJsonPath)"
395398
ConfigurationFiles="@(_WasmJsConfigStaticWebAsset)"
@@ -797,7 +800,7 @@ Copyright (c) .NET Foundation. All rights reserved.
797800
DebugBuild="false"
798801
DebugLevel="$(WasmDebugLevel)"
799802
LinkerEnabled="$(PublishTrimmed)"
800-
CacheBootResources="$(BlazorCacheBootResources)"
803+
CacheBootResources="$(_BlazorCacheBootResources)"
801804
MergeWith="@(_WasmDotnetJsForPublish)"
802805
OutputPath="$(IntermediateOutputPath)$(_WasmPublishBootConfigFileName)"
803806
ConfigurationFiles="@(_WasmPublishConfigFile)"

0 commit comments

Comments
 (0)