简体   繁体   中英

Performance issues downloading JS and CSS files on Blazor App even when they are cached

We are building an app using Blazor Server side and Syncfusion controls. They are being hosted on Azure. The pages are taking a very long time to load. I have tracked down one thing that seems to be a problem. When the page is loaded, it is looking for JS and CSS files. Even though those pages are cached (HTTP 304), it still takes sometimes 10 to 15 seconds to make that determination. For each file that has a 304, it is transmitting about 373 bytes but takes a very long time to do it; sometimes upward of 15 seconds to respond. Some files take only a few milliseconds though and I can't figure the difference. The cumulative effect is that it is taking a very long time to load pages. I did a great deal of searching over the weekend but found nothing that deals with this problem. Also, I tried to find a way to control caching in blazor server but also could not find anything.

这张图显示了 3 个文件,都是 304,都传输了 373B,但一个用了 471 毫秒,其他用了 9 或 15 秒

Update: Well, I was able to find some help. By adding this to the startup, I was able to stop Bazor from version checking most of the JS files but it still hangs on blazor.server.js.

            app.UseStaticFiles(new StaticFileOptions()
            {
                OnPrepareResponse = (context) =>
                {
                    var headers = context.Context.Response.GetTypedHeaders();
                    headers.CacheControl = new Microsoft.Net.Http.Headers.CacheControlHeaderValue
                    {
                        Public = true,
                        MaxAge = TimeSpan.FromDays(30),
                        NoCache = false
                    };

                }
            });

We have created a Blazor Server application with Syncfusion Blazor components and hosted the same in azure. Unfortunately, we are not able to replicate the reported scenario in our end. The script files loaded around ~659ms. Also, we would like to let you know that the download time depends on many factors such as network connection, bandwidth value, server setting, etc.. Please refer to the below doc for more details.

https://developers.google.com/web/tools/chrome-devtools/network/issues#long-content-download

Please find the below screenshot and hosted sample which are mentioned below for your reference.

Hosted Link: https://blazorci.azurewebsites.net/staging/blazorPerformance

Could you please check the above information and get back to us with more details so that we can analyze based on that and provide you a better solution?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM