Blazor Chrome缓存问题 [英] Blazor Chrome caching issues

查看:121
本文介绍了Blazor Chrome缓存问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有这个Blazor SPA,我已经在Webhotel上发布到IIS.我的问题是Chrome以某种方式缓存了Blazor程序集,因此无论我重新部署多少次,我仍然会得到旧的dll.我可以使用 chrome --disable-application-cache --incognito 启动一个新的干净的Chrome,确实可以获取新的dll,但是如何正确解决呢?亲切的问候

I have this Blazor SPA I have published to IIS on a webhotel. My problem is that Chrome is somehow caching my Blazor assembly so no matter how many times I redeploy I still get the old dll. I can start up a new clean Chrome with chrome --disable-application-cache --incognito and that does indeed get the fresh dll but how do I fix this properly? Kind regards

推荐答案

如果您不希望使用PWA功能,以下内容将为您提供帮助.

The following helps IF you don't want PWA features.

我从PWA开始了我的项目(以防万一我以后想要它),但事实证明,即使只是浏览时,它也会导致此问题.尝试向service-worker.published.js添加注释或版本控制,但这无济于事.我正在使用Blazor 3.2.1版.

I started my project with PWA (just in case I wanted it later) but it turned out to cause this problem even when simply browsing. Tried adding comments or versioning to service-worker.published.js but that didn't help. I'm using Blazor version 3.2.1.

使用PWA.在浏览器中检查缓存时,我确实看到出现了最新的service-worker.published.js,并且确实下载了新的脱机缓存.但是浏览器之所以继续使用旧版本,是出于我无法理解的原因.

With PWA. When checking the cache in the browser I do see the latest service-worker.published.js appearing, and a new offline cache does get downloaded. But the browser keeps using the older ones for a reason beyond my understanding.

要删除PWA:

  1. 从wwwroot删除以下文件:

/wwwroot/manifest.json
/wwwroot/service-worker.js
/wwwroot/service-worker.published.js

  1. 从/wwwroot/index.html
  2. 删除此行

<script>navigator.serviceWorker.register('service-worker.js');</script>

  1. 从csproj文件中删除这些行

<ServiceWorkerAssetsManifest>service-worker-assets.js</ServiceWorkerAssetsManifest>
<ServiceWorker Include="wwwroot\service-worker.js" PublishedContent="wwwroot\service-worker.published.js" />

这篇关于Blazor Chrome缓存问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆