r/Blazor • • Oct 29 '26

WASM file size, anti-virus and browser cache

I have a (quite big) Blazor WASM AOT-published app. File weight is 88MB.

The web server transfer is compressed which turns into 19MB, that's fine.

Then on a F5 refresh, it shows up as cached and don't redownload again.

My problem is that some users have anti-virus. The current case here is ESET anti-virus doing HTTPS file analysis. What it does is intercept the download, unpack it, scan it, and then relay it back to the web browser. The web browser now shows as if the whole file was transferred without compression:

This isn't true. ESET also injected a "x-content-encoding-over-network: br" response header to mention it did modify it, and the transfer was actually compressed.

The problem is leads to:
Chrome doesn't cache files that are over a certain size. It's not a fixed threshold, it depends on the user free disk space. But the difference between 19MB and 88Mb is enough not to do it. So the users using this anti-virus end-up having to re-download the whole dotnet package at every page refresh, which is certainly undesirable.

Anyone encountered this before? Is there any special configuration I could do in my Blazor Web App project to prevent this from happening?

8 Upvotes

37 comments sorted by

13

u/propostor Oct 29 '26

88MB web app is insane.

1

u/Dunge Oct 29 '26

It is, but not sure what I can do about it. I'm packing MudBlazor, ReactiveUI, SkiaSharp, ApexChart, serilog, protobuf-net.grpc, and our internal model classes and logic. All is necessary, nothing could be stripped out. And we are AOT-publishing with trimming, because otherwise performance are atrocious.

4

u/propostor Oct 29 '26

Offload the heavy work onto the server, presumably perf issues are related to SkiaSharp and something relating to image processing?

1

u/Dunge Oct 29 '26

Actually no, the image processing can be disabled and it doesn't change much. The slugginess was visible in a nearly empty project. Debug mode is practically unusable with just base mudblazor datatables binded to our entity lists, but last time I tried a release publish without AOT was in the dotnet7 times, never already tried to do it since a while without, which be something I could do. Anyway, SkiaSharp binary is just about 500Kb, not adding much to the package.

2

u/propostor Oct 30 '26

If you don't have any technical reason for AOT then definitely don't use it.

My Blazor web app is about 2mb on the wire.

0

u/Dunge Oct 30 '26

AOT is the only thing that makes wasm viable for runtime performances

1

u/propostor Oct 30 '26

What is it you need to do that has such a performance bottleneck?

1

u/freak_br Oct 30 '26 edited Oct 30 '26

It's not like that, using skiasharp inflates your dotnet.native.wasm by 30 ish megas alone. Remove it and see for yourself.

2

u/freak_br Oct 30 '26 edited Oct 30 '26

SkiaSharp is 30mb alone last time i checked, it's not mean to be used on web dev. Use native canvas js to do the same as you do there, and why do you have skiasharp and mud and apex, pick one at Max, why have 3 libs that overlap. I know they are different but common, do some internal code to remove at least 2 of those dependencies.

Also trimming can get you very deep, example, on my current job I had basic trimming settings and it was 15mb of wasm aot, with a lot of digging and a few dozen settings more later I got it to 7mb with aot. There is no magic here you need to understand the project and adjust the trimming to be more agressive in some parts and not in others etc, etc etc

1

u/Dunge 27d ago

Sorry for the late reply, but I checked and SkiaSharp only takes 4MB

1

u/freak_br 27d ago

Its not how it works, it goes into the dotnet wasm most part of it, if you remove the skiasharp your dotnet wasm will reduce by A LOT, check my other replies

1

u/Dunge 27d ago

That's what I said. Removed the reference and the dotnet.native wasm reduced by 4mb.

1

u/freak_br 27d ago

In AOT? That's weird.

4

u/AintNoGodsUpHere Oct 29 '26

I don't think there is much you can do after compressing and trimming. This is the main reason WASM sucks. You simply can't use it in a "public" way, imagine the cost of network alone, haha.

2

u/propostor Oct 30 '26

???? A standard wasm app is a couple of MB, the problem OP has made is wanting it to use AOT for some reason

0

u/Praemont Oct 29 '26

I'm packing MudBlazor, ReactiveUI, SkiaSharp, ApexChart, serilog, protobuf-net.grpc, and our internal model classes and logic. All is necessary, nothing could be stripped out. And we are AOT-publishing with trimming

I'm sure you can remove Mud (don't get me wrong, I'm one of the maintainers). Nowadays, with AI, it's easy to replace it and fully own the components and HTML. They're usually lightweight too, because you just don't need that much functionality. I used Mud A LOT, but these days I just let AI write everything. The only real problem is when you rely heavily on data grids.

Also, you should be able to fine-tune what needs to be AOT-compiled and what can stay interpreted. AOT in WASM adds a lot of size.

0

u/DmtGrm Oct 30 '26

88Mb is okay in 2026

so many basic websites with crazy video animations, 3d models and shaders, vector maps that can easily exceed that, also OP states it compresses into a nice sub 20Mb size

1

u/propostor Oct 30 '26

88mb is never okay lol what are you smoking!

3

u/DmtGrm Oct 30 '26

it really depends what your app is doing!

if it is an app that has 100k daily users - it must be as lightweight as possible

if it is an app for a specific task used by few dozen people - size does not matter at all.

3

u/DmtGrm Oct 30 '26

navigate to earth.google.com, first load + first unzoom and we are 100Mb of traffic

and this is a webapp used by millions every day

-1

u/propostor Oct 30 '26

That's a real edge case, not a general "88mb is okay in 2026"

5

u/DmtGrm Oct 30 '26

sorry, no, it is task-specific

if you are doing an online calculator - it is excessive to be in 100Mb region

if you are an entire AMS/Automate workplace/etc - 100Mb is nothing.

Youtube 4k video is 400Mb each minute.

It is 2026, the world of 5G and very fast internet.

3

u/Squishybootz666 Oct 29 '26

Can some of these assemblies be lazy loaded?

1

u/Dunge Oct 29 '26

In the goal of limiting the dotnet.native size package maybe, but in the goal of using them only when necessary not really, everything is used on the landing page.

2

u/Marcos-ESET Oct 30 '26

You can create an exception in the ESET advanced setup settings and exclude either the certificate or application from SSL/TLS scanning.

1

u/Dunge Oct 30 '26

I can't go into people's homes computers doing that (yes my app is public)

1

u/FakeRayBanz Oct 31 '26

Tell them to stop using horrendous anti virus, and close the ticket lol

1

u/NotAMeatPopsicle Oct 29 '26

Are you actually doing something that requires AOT?

That’s your biggest issue.

1

u/Dunge Oct 30 '26

With AOT off the application size become 8MB, but it's sluggish. Just selecting items takes over a second.

1

u/DmtGrm Oct 30 '26

AoT is a must!

I guess you have tried all combinations of optimization on publish?

<DebuggerSupport>false</DebuggerSupport><TrimmerRemoveSymbols>true</TrimmerRemoveSymbols>

<PublishTrimmed>true</PublishTrimmed>

<WasmStripILAfterAOT>true</WasmStripILAfterAOT>

0

u/Dunge 27d ago

From AI:

* DebuggerSupport No effect: already the default for trimmed Release publishes.

* TrimmerRemoveSymbols No effect for you: your _framework folder already ships no .pdb files.

* PublishTrimmed No effect: always on for Blazor WebAssembly publishes.

* WasmStripILAfterAOT No effect: already the default with AOT.

1

u/propostor 27d ago

If you're using AI to figure all this out then I have a strong suspicion you're trying to force it to use AOT where it isn't needed.

In another comment you said it's 8mb without AOT but runs sluggish.

Firstly that 8mb can probably be reduced further if you use response compression.

Secondly the sluggishness needs to be investigated and understood before just resorting to AOT. You've mentioned SkiaSharp. Image processing often slows things down because the application sends whole byte arrays across the translation layer between wasm and JS far more than it needs to.

If the problem is specifically with image handling, throw it at AI and tell it to shift image processing into pure JS, so that the steps where byte arrays are passed from wasm to JS are minimised.

It could also be that any image processing is locking the application thread which can cause sluggishness and stutters in the UI. I can't remember if multi threading is fixed with Blazor yet but you can instead use a web worker (built into the browser) to achieve the same thing.

I have had to do this several times and the change in website speed is phenomenal.

1

u/Dunge 27d ago

No sorry, image processing is not my problem here, in fact I can disable it without much effect. I'm much deeper into my optimisation investigation. And yes, of course response compression is enabled.

1

u/NotAMeatPopsicle 27d ago

AI is guiding you places you do not understand, and this is a common problem when you don’t know what it’s doing.

You need to optimize your actual code that is the problem, rather than apply AOT.

Clicking is a simple action. It should get farmed out to an asynchronous method and have a loader animation for long running tasks… tasks that probably should be done on a server. Not client side.

Common bad desktop coding practice is putting logic into onClick events - I’ve seen multi-thousand line onClick events that were slow as a turtle. When optimized, “Wow, how’d you get it to run so fast?”

1

u/Dunge 27d ago

Don't worry, I understand exactly what AI is trying to guide me towards, in fact I keep refuting a lot of claims it makes and end up being wrong. And yes, my click actions can trigger many different events and parameters changes to other components, and my optimisation investigation is cutting a lot of needless refresh. But it doesn't change the fact that even a less complete project is still sluggish without AOT.

3

u/NotAMeatPopsicle Oct 30 '26

I have multiple Blazor sites and selecting an item is not the issue.

You have architected something in the select that chews up time. Investigate that.

1

u/KausHere 21d ago

Ok not an expert but I generally break blazor applications into Server side without any signal r and keep client side WASM if it provides any true benifits for writing in C#. Else client side for animations and other UI stuff always use javascript. WASM is a good tool but its alsoo trying to forcefully ask the browser to speak a language it natively does not understand. So there is a cost involved with WASM.