fix(pwa): 修复部署切换后的懒加载失败 - #44
Open
shellRaining wants to merge 3 commits into
Open
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
1 Skipped Deployment
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
背景
新版本部署后,旧标签页仍可能请求上一版的懒加载资源。原来的 SPA 回退会把缺失的
/assets/*请求改写为index.html,浏览器和 Service Worker 因而可能收到并缓存200 text/html,最终在切换页面时表现为路由加载失败。长时间打开的页面也没有主动触发 Service Worker 更新检查。改动
CacheFirst,并按状态码和 Content-Type 校验缓存写入。vite:preloadError,显示“当前版本已失效”提示,由用户确认后更新或刷新。验证
vp run readyvite:preloadError后显示版本失效提示,“稍后”和“立即更新”行为正常。/assets/*.js返回 404 且不是 HTML。额外说明
根目录
README.md的表格变化只是vp check --fix对主分支近期内容的格式化,没有修改文意。