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

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

问题描述

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

解决方案

如果您不想要 PWA 功能,以下内容会有所帮助.

我用 PWA 开始了我的项目(以防万一我以后需要它)但结果即使只是浏览时也会导致这个问题.尝试向 service-worker.published.js 添加评论或版本控制,但这没有帮助.我使用的是 Blazor 3.2.1 版.

使用 PWA.在浏览器中检查缓存时,我确实看到了最新的 service-worker.published.js 出现,并且确实下载了一个新的离线缓存.但是浏览器由于我无法理解的原因一直使用旧版本.

删除 PWA:

  1. 从 wwwroot 中删除以下文件:

<块引用>

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

  1. 从/wwwroot/index.html 中删除这一行

<块引用>

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

<块引用>

service-worker-assets.js<ServiceWorker Include="wwwrootservice-worker.js";PublishedContent="wwwrootservice-worker.published.js";/>

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

解决方案

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

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.

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.

To remove PWA:

  1. Delete the following files from wwwroot:

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

  1. Delete this line from /wwwroot/index.html

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

  1. Delete those lines from your csproj file

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

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

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