首页 > 解决方案 > 手动更新 Blazor WebAssembly 应用程序

问题描述

我们即将发布我们的第一个 Blazor WebAssembly 独立(即不托管在 .Net Core 上)应用程序。我开始爱上 Blazor,并期待用它制作一些出色的应用程序!然而推送应用更新一直是一件令人头疼的事情!似乎有一个难以更新的持久缓存,而且超级烦人!可能是我缺乏理解,但它似乎并没有像每个人所说的那样起作用。

我想构建某种应用程序版本控制系统和一种通知用户有可用更新的方法。最重要的是,我想让用户能够手动执行更新……但是搜索这个主题一直很困难。我一定不能使用正确的关键字,因为 Blazor 似乎没有这方面的文档?

如果我将 Blazor 排除在搜索查询之外,如果我理解正确,其他 SPA 应用程序似乎会通过 Service Worker 执行此操作?然而,这完全是另一个深层次的主题,如果我的理解是正确的,显然我必须学习一些东西?

谁能引导我朝着正确的方向学习如何创建这样的更新过程?

标签: blazorsingle-page-applicationservice-workerblazor-webassembly

解决方案


Ok... so my answer is a patch for now. It took a while to figure out because I had an idea of what was happening... in not being able to clear the cache like I wanted... I just didn't understand why. Lots of tutorials and training on Blazor but the service worker should be one of those that should be included for WebAssembly apps. Unfortunately at this time I couldn't find anything until I left Blazor out of my Google searches and just researched SPA caching issues in general.

Granted, the service worker itself is not Blazor specific technology... however if you are building SPA's it's something you should at the very least be aware of and learn how to use. However it's not a light subject so for now I simply commented out all of the code in service-worker.published.js and replaced it with the one liner service worker that is used for development i.e. the service-worker.js file: enter image description here

I know this isn't a final fix... eventually I will have to take pickup learning how to use the service worker to it's full extent. But for now it works as I want in that I want my development changes to be immediately available.


推荐阅读