Aspnetcore: allow framework assemblies to be transferred over cdn

Created on 16 May 2018  路  8Comments  路  Source: dotnet/aspnetcore

I know that we're caching the framework dlls, the initial load is still very heavy, and as more and more applications start using blazor it would make a significant impact to serve the dll over a cdn, we can use the nuget or assembly version number to be the differentiator.

area-blazor

All 8 comments

Thanks for the feedback!

There shouldn't be anything that prevents you from using a CDN with Blazor today. We also plan to look at providing a CDN for the main Blazor static assets. This work is tracked by https://github.com/aspnet/blazor/issues/22

We also have a bunch of work items to reduce the initial download size. See aspnet/AspNetCore#5469 for example.

Closing this as we think we have this feedback tracked elsewhere. I hope that's ok!

@danroth27 I had a look at aspnet/AspNetCore#5462 before creating this ticket, but since it didn't have any description, so wasn't sure about its scope. Also, I am already using CDN for static CSS assets and my head in index.html looks like this

<link rel="stylesheet" href="https://ajax.aspnetcdn.com/ajax/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">

but my point was regarding the DLL files, like System.dll as we don't make the request directly for them but rather blazor does it, so my suggestion was to use CDN for these DLL files

@danroth27 I had a look at the code and found out that we are picking up the DLL on boot at https://github.com/aspnet/Blazor/blob/dev/src/Microsoft.AspNetCore.Blazor.Browser.JS/src/Boot.ts#L29 which in turns receives from "blazor-boot" script tag which is updated in https://github.com/aspnet/Blazor/blob/dev/src/Microsoft.AspNetCore.Blazor.Build/Core/IndexHtmlWriter.cs

I'll tinker around more and will get back if I find a way to make the source path for framework DLL configurable

My point was regarding the DLL files, like System.dll as we don't make the request directly for them but rather blazor does it, so my suggestion was to use CDN for these DLL files

Ah, I see what you are saying. Yes, I may have misspoke when I said this was possible today given the nature of how we retrieve the reference assemblies.

@SteveSandersonMS Is there any way currently to control where the reference assemblies are retrieved from so that they can be put on a CDN? Or is enabling that ability still need to be done as part of aspnet/AspNetCore#5462?

Is anything happening here?

I try to load blazor app from azure CDN linked to azure storage but no success yet.

Blazor is working well as static website from azure storage.

I want to enable it from CDN because of load speed and also CDN compression support.

I put whole (not only dlls) blazor app to CDN and when calling index.html it give this error:
WASM: System.InvalidOperationException: 'Router' cannot find any component with a route for '/index.html', and no fallback is defined.

@Lupusa87 Your error message suggests you were trying to navigate to /index.html, but don't have any route defined for that. Were you imagining that /index.html is the same thing as /? If so, it isn't. They are distinct URLs so you should either navigate to / and make sure your server returns the correct HTML for that URL, or declare a route for /index.html by adding @page "/index.html" into your root page.

@SteveSandersonMS

Blazor was working well as static web app hosted on azure storage but files where not compressed and download size was large.
I was trying to host it on azure CDN, I wanted do it because azure CDN has support for compression.

So problem was not route but something else.

I was playing with different approaches, finally router issue gone but render issue occur and I ended with CDN for that time, because I managed compress asserts in storage and it has smaller download size now.
demo

Main issue here is how to host blazor app on CDN entirely or load some dlls from cdn?
Can we have configuration file or some way to tell blazor from where to load dlls which it expects to have in _Framework folder?

@Lupusa87 Maybe you can use the same techniques some use to serve fast fonts using Service Workers. Some articles:

If you go down that path, notes at https://github.com/aspnet/Blazor/issues/828#issuecomment-484258086 could be of interest.

Was this page helpful?
0 / 5 - 0 ratings