惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

WordPress大学
WordPress大学
V
Visual Studio Blog
P
Privacy International News Feed
月光博客
月光博客
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
L
Lohrmann on Cybersecurity
N
News and Events Feed by Topic
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
Apple Machine Learning Research
Apple Machine Learning Research
阮一峰的网络日志
阮一峰的网络日志
Webroot Blog
Webroot Blog
T
Threatpost
宝玉的分享
宝玉的分享
The Last Watchdog
The Last Watchdog
小众软件
小众软件
L
LINUX DO - 最新话题
C
Cisco Blogs
T
Troy Hunt's Blog
Schneier on Security
Schneier on Security
酷 壳 – CoolShell
酷 壳 – CoolShell
www.infosecurity-magazine.com
www.infosecurity-magazine.com
雷峰网
雷峰网
G
GRAHAM CLULEY
有赞技术团队
有赞技术团队
Know Your Adversary
Know Your Adversary
博客园 - 叶小钗
罗磊的独立博客
V
V2EX
博客园 - Franky
P
Proofpoint News Feed
SecWiki News
SecWiki News
腾讯CDC
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
Jina AI
Jina AI
博客园 - 三生石上(FineUI控件)
S
Secure Thoughts
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
Google DeepMind News
Google DeepMind News
Attack and Defense Labs
Attack and Defense Labs
人人都是产品经理
人人都是产品经理
The Cloudflare Blog
PCI Perspectives
PCI Perspectives
V2EX - 技术
V2EX - 技术
Google DeepMind News
Google DeepMind News
Last Week in AI
Last Week in AI
aimingoo的专栏
aimingoo的专栏
Cisco Talos Blog
Cisco Talos Blog
N
News and Events Feed by Topic
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
S
SegmentFault 最新的问题

木灵鱼儿

Windows 下如何快速复制目录的同时排除指定的目录和文件 - 木灵鱼儿 x86多网口软路由+pve+爱快ikuai+iStoreOS实现组网和翻墙 - 木灵鱼儿 如何在 Vite 项目中优雅地展示用户协议?(Markdown 转 Vue 组件方案) - 木灵鱼儿 Vue 路由守卫进阶:用策略模式告别 if-else - 木灵鱼儿 16 Python for循环 - 木灵鱼儿 15 Python while循环 - 木灵鱼儿 如何生成一个“扫码连WIFI”的二维码 - 木灵鱼儿 14 Python 分支语句if - 木灵鱼儿 13 Python 字符串详解 - 木灵鱼儿 12 Python 语句、表达式与运算符 - 木灵鱼儿
生产部署时动态导入 Chunk 失效的实用回退方案 - 木灵鱼儿
木灵鱼儿 · 2026-03-16 · via 木灵鱼儿

前言与痛点

在单页应用(SPA)的日常开发与运维中,我们经常会遇到因旧版本文件失效导致的用户访问异常。一个典型的场景如下:

  1. 10:00 —— 部署了版本 V1,用户正常访问并停留在页面 A。
  2. 11:00 —— 部署了版本 V2。此时,服务器上的 JS 文件带有全新的 Hash 后缀,V1 版本的旧 JS 文件已被新版本覆盖或被清理。
  3. 11:05 —— 停留在页面 A 的用户尝试点击路由跳转到页面 B。此时浏览器尝试通过 import() 动态加载页面 B 对应的 chunk 文件,但服务器上该文件已不存在,导致请求返回 404。

此时,基于 ESM 构建的工具(如 Vite)在控制台通常会抛出以下错误,导致前端路由完全卡死,页面毫无反应:

TypeError: Failed to fetch dynamically imported module: https://.../assets/xxxx.abc123.js

在频繁迭代、敏捷部署的业务环境中,如果不妥善处理此类问题,将会导致用户访问失败,严重影响用户体验。

此处内容已隐藏回复后方可阅读。

版权申明

本文系作者 @木灵鱼儿 原创发布在木灵鱼儿站点。未经许可,禁止转载。