Skip to content

[browser] Remove custom cache #114901

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

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions src/mono/browser/runtime/dotnet.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -166,10 +166,6 @@ type MonoConfig = {
* debugLevel < 0 enables debugging and disables debug logging.
*/
debugLevel?: number;
/**
* Gets a value that determines whether to enable caching of the 'resources' inside a CacheStorage instance within the browser.
*/
cacheBootResources?: boolean;
/**
* Delay of the purge of the cached resources in milliseconds. Default is 10000 (10 seconds).
*/
Expand Down
13 changes: 1 addition & 12 deletions src/mono/browser/runtime/loader/assets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import { ENVIRONMENT_IS_NODE, ENVIRONMENT_IS_SHELL, ENVIRONMENT_IS_WEB, ENVIRONM
import { createPromiseController } from "./promise-controller";
import { mono_log_debug, mono_log_warn } from "./logging";
import { mono_exit } from "./exit";
import { addCachedReponse, findCachedResponse } from "./assetsCache";
import { getIcuResourceName } from "./icu";
import { makeURLAbsoluteWithApplicationBase } from "./polyfills";
import { mono_log_info } from "./logging";
Expand Down Expand Up @@ -675,7 +674,7 @@ const totalResources = new Set<string>();
function download_resource (asset: AssetEntryInternal): LoadingResource {
try {
mono_assert(asset.resolvedUrl, "Request's resolvedUrl must be set");
const fetchResponse = download_resource_with_cache(asset);
const fetchResponse = fetchResource(asset);
const response = { name: asset.name, url: asset.resolvedUrl, response: fetchResponse };

totalResources.add(asset.name!);
Expand Down Expand Up @@ -708,16 +707,6 @@ function download_resource (asset: AssetEntryInternal): LoadingResource {
}
}

async function download_resource_with_cache (asset: AssetEntryInternal): Promise<Response> {
let response = await findCachedResponse(asset);
if (!response) {
response = await fetchResource(asset);
addCachedReponse(asset, response);
}

return response;
}

function fetchResource (asset: AssetEntryInternal): Promise<Response> {
// Allow developers to override how the resource is loaded
let url = asset.resolvedUrl!;
Expand Down
205 changes: 0 additions & 205 deletions src/mono/browser/runtime/loader/assetsCache.ts

This file was deleted.

3 changes: 0 additions & 3 deletions src/mono/browser/runtime/loader/globals.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import { mono_download_assets, resolve_single_asset_path, retrieve_asset_downloa
import { mono_log_error, set_thread_prefix, setup_proxy_console } from "./logging";
import { invokeLibraryInitializers } from "./libraryInitializers";
import { deep_merge_config, isDebuggingSupported } from "./config";
import { logDownloadStatsToConsole, purgeUnusedCacheEntriesAsync } from "./assetsCache";

// if we are the first script loaded in the web worker, we are expected to become the sidecar
if (typeof importScripts === "function" && !globalThis.onmessage) {
Expand Down Expand Up @@ -122,8 +121,6 @@ export function setLoaderGlobals (
resolve_single_asset_path,
setup_proxy_console,
set_thread_prefix,
logDownloadStatsToConsole,
purgeUnusedCacheEntriesAsync,
installUnhandledErrorHandler,

retrieve_asset_download,
Expand Down
5 changes: 0 additions & 5 deletions src/mono/browser/runtime/loader/run.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import { runtimeHelpers, loaderHelpers } from "./globals";
import { init_globalization } from "./icu";
import { setupPreloadChannelToMainThread } from "./worker";
import { importLibraryInitializers, invokeLibraryInitializers } from "./libraryInitializers";
import { initCacheToUseIfEnabled } from "./assetsCache";


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

prepareAssets();

await initCacheToUseIfEnabled();

init_globalization();

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

const promises = importModules();

await initCacheToUseIfEnabled();

streamingCompileWasm(); // intentionally not awaited

setTimeout(async () => {
Expand Down
8 changes: 0 additions & 8 deletions src/mono/browser/runtime/startup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -338,14 +338,6 @@ async function onRuntimeInitializedAsync (userOnRuntimeInitialized: (module:Emsc

if (!runtimeHelpers.mono_wasm_runtime_is_ready) mono_wasm_runtime_ready();

if (loaderHelpers.config.debugLevel !== 0 && loaderHelpers.config.cacheBootResources) {
loaderHelpers.logDownloadStatsToConsole();
}

setTimeout(() => {
loaderHelpers.purgeUnusedCacheEntriesAsync(); // Don't await - it's fine to run in background
}, loaderHelpers.config.cachedResourcesPurgeDelay);

// call user code
try {
userOnRuntimeInitialized(Module);
Expand Down
4 changes: 0 additions & 4 deletions src/mono/browser/runtime/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,10 +118,6 @@ export type MonoConfig = {
*/
debugLevel?: number,

/**
* Gets a value that determines whether to enable caching of the 'resources' inside a CacheStorage instance within the browser.
*/
cacheBootResources?: boolean,
/**
* Delay of the purge of the cached resources in milliseconds. Default is 10000 (10 seconds).
*/
Expand Down
2 changes: 0 additions & 2 deletions src/mono/browser/runtime/types/internal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -164,9 +164,7 @@ export type LoaderHelpers = {

retrieve_asset_download(asset: AssetEntry): Promise<ArrayBuffer>;
onDownloadResourceProgress?: (resourcesLoaded: number, totalResources: number) => void;
logDownloadStatsToConsole: () => void;
installUnhandledErrorHandler: () => void;
purgeUnusedCacheEntriesAsync: () => Promise<void>;

loadBootResource?: LoadBootResourceCallback;
invokeLibraryInitializers: (functionName: string, args: any[]) => Promise<void>,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ Copyright (c) .NET Foundation. All rights reserved.

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

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

<_BlazorCacheBootResources>$(BlazorCacheBootResources)</_BlazorCacheBootResources>
<_BlazorCacheBootResources Condition="'$(_BlazorCacheBootResources)' == '' and '$(_TargetingNET100OrLater)' != 'true'">true</_BlazorCacheBootResources>
<_BlazorEnableTimeZoneSupport>$(BlazorEnableTimeZoneSupport)</_BlazorEnableTimeZoneSupport>
<_BlazorEnableTimeZoneSupport Condition="'$(_BlazorEnableTimeZoneSupport)' == ''">true</_BlazorEnableTimeZoneSupport>
<_WasmInvariantGlobalization>$(InvariantGlobalization)</_WasmInvariantGlobalization>
Expand Down Expand Up @@ -218,6 +219,7 @@ Copyright (c) .NET Foundation. All rights reserved.
<!-- Workaround for https://github.com/dotnet/sdk/issues/12114-->
<PublishDir Condition="'$(AppendRuntimeIdentifierToOutputPath)' != 'true' AND '$(PublishDir)' == '$(OutputPath)$(RuntimeIdentifier)\$(PublishDirName)\'">$(OutputPath)$(PublishDirName)\</PublishDir>
</PropertyGroup>
<Warning Message="Custom Blazor cache has been removed and setting 'BlazorCacheBootResources' has no effect. Follow a migration path at TODO: PLACEHOLDER FOR LINK" Condition="'$(_BlazorCacheBootResources)' != '' and '$(_TargetingNET100OrLater)' == 'true'" />
</Target>

<Target Name="ResolveWasmOutputs" DependsOnTargets="_ResolveWasmOutputs" />
Expand Down Expand Up @@ -390,7 +392,7 @@ Copyright (c) .NET Foundation. All rights reserved.
DebugBuild="true"
DebugLevel="$(WasmDebugLevel)"
LinkerEnabled="false"
CacheBootResources="$(BlazorCacheBootResources)"
CacheBootResources="$(_BlazorCacheBootResources)"
MergeWith="@(_WasmDotnetJsForBuild)"
OutputPath="$(_WasmBuildBootJsonPath)"
ConfigurationFiles="@(_WasmJsConfigStaticWebAsset)"
Expand Down Expand Up @@ -799,7 +801,7 @@ Copyright (c) .NET Foundation. All rights reserved.
DebugBuild="false"
DebugLevel="$(WasmDebugLevel)"
LinkerEnabled="$(PublishTrimmed)"
CacheBootResources="$(BlazorCacheBootResources)"
CacheBootResources="$(_BlazorCacheBootResources)"
MergeWith="@(_WasmDotnetJsForPublish)"
OutputPath="$(IntermediateOutputPath)$(_WasmPublishBootConfigFileName)"
ConfigurationFiles="@(_WasmPublishConfigFile)"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,11 @@ private void WriteBootConfig(string entryAssemblyName)
result.mainAssemblyName = entryAssemblyName;
result.globalizationMode = GetGlobalizationMode().ToString().ToLowerInvariant();

if (CacheBootResources)
result.cacheBootResources = CacheBootResources;
if (!IsTargeting100OrLater())
{
if (CacheBootResources)
result.cacheBootResources = CacheBootResources;
}

if (LinkerEnabled)
result.linkerEnabled = LinkerEnabled;
Expand Down
Loading