Modern Web System Architecture Roadmap
From Browser Engine to Web Platform, Full-Stack Runtime, Deployment, and Architecture Decisions
Part 1: Web System Worldview and Engineering Mental Model
Chapter 1: Modern Web Integration Surface
- 1.1 Web as a Broader System(现代 Web 由浏览器、网络协议、运行时、服务器、数据层、缓存层和部署环境共同形成系统)
- 1.2 The Browser as a Client-Side Operating Environment(浏览器是拥有进程模型、网络栈、解析器、渲染管线、JavaScript runtime、存储、安全策略和平台 API 的客户端运行环境)
- 1.3 The Server as Request Handler, Policy Enforcer, and Data Boundary(服务器可以返回 JSON、HTML、stream 或 redirect,并承担请求处理、身份校验、权限判断、业务逻辑、数据访问、缓存协调和错误恢复等职责)
- 1.4 The Network as a Semantic Boundary(URL、HTTP、header、cookie、cache-control、redirect、streaming 等机制共同定义了浏览器与服务器之间的语义边界)
- 1.5 The Web Platform as a Shared Capability Surface(HTML、CSS、DOM、Fetch、Storage、Worker、Service Worker、WebRTC、WebGPU 等能力构成 Web 平台)
- 1.6 Full-Stack Architecture as Cross-Runtime Coordination(Web full-stack,核心是 browser、server、edge、database、cache、build time、deployment runtime 之间的协同)
- 1.7 Frameworks as Partial Integrators of the Web System(React、Next.js、Astro、SvelteKit、Nuxt、Hono、tRPC、Prisma、Vite 等工具只封装部分 Web 系统能力,仍需要回到平台边界分析)
- 1.8 The Core Question: Where Does This Code Run, and Which Boundary Does It Cross?(分析现代 Web 的核心问题是判断代码运行在 browser、server、edge、build time 还是 database boundary,以及它跨越了哪些系统边界)
- 1.9 The Handbook’s Unifying Model: Path, Boundary, State, and Failure(本书后续所有主题都围绕四个统一维度展开:请求或交互穿过的路径、跨越的边界、改变的状态、可能出现的失败模式)
Chapter 2: Web Architecture Boundary Expansion
- 2.1 The Old Two-Sided Model: Browser Requests, Server Responds(早期 Web 可以粗略分析为浏览器发出 HTTP 请求、服务器返回 HTML 或资源,但这个模型只能解释最基础的页面访问)
- 2.2 Client-Side Applications Expanded the Browser Boundary(追踪 JavaScript、DOM API、Fetch、History、Storage、Worker 等能力如何扩大浏览器责任边界)
- 2.3 Server-Side Rendering and Full-Stack Frameworks Moved UI Work Back to the Server(SSR 与 full-stack framework 把页面生成、数据读取、request context、cache policy 和 hydration 重新放入架构判断)
- 2.4 Edge Runtime and CDN Cache Created a Third Execution Zone(现代 Web 会在浏览器、源服务器、CDN、edge runtime、worker、regional cache、middleware 等多个执行区之间运行)
- 2.5 Database, Storage, and Cache Are Part of the User-Visible System(数据库事务、对象存储、浏览器缓存、CDN cache 和 query cache 都会影响用户看到的数据版本、延迟和错误)
- 2.6 Build Time Became a Real Architectural Boundary(现代 Web 应用会在 build time 生成静态页面、拆分 bundle、生成 server output、生成 edge output、注入资源关系和环境变量)
- 2.7 Deployment Runtime Changes What the Same Code Can Do(比较 browser、Node.js、serverless、edge、static hosting 和 build time 的能力边界)
- 2.8 Modern Web Architecture Is Multi-Boundary Coordination(现代 Web 需要同时协调 browser、server、edge、CDN、database、build time、deployment runtime 的责任归属)
- 2.9 The Practical Question: Which Runtime Owns This Responsibility?(分析任何现代 Web 技术时,首先要问的是它在哪个 runtime 执行、拥有哪个状态、跨越哪个边界、失败时由谁恢复)
Chapter 3: Browser, Server, Edge, Database, CDN, and Build-Time Boundaries
- 3.1 Browser Boundary: User Intent, Rendering, Storage, and Policy Enforcement(browser boundary 承接用户输入、页面渲染、交互反馈、本地存储、权限提示和浏览器安全策略,是用户可见体验最直接的执行边界)
- 3.2 Server Boundary: Request Context, Business Logic, and Trusted Data Access(server boundary 拥有更可信的执行环境,可以读取 secret、访问数据库、执行业务规则、生成响应并控制哪些数据暴露给浏览器)
- 3.3 Edge Boundary: Regional Execution, Cache Proximity, and Early Request Decisions(edge boundary 靠近用户,适合执行重定向、缓存判断、轻量身份检查、A/B routing、header 改写和低延迟响应,但通常受到 runtime 能力和资源限制)
- 3.4 Database Boundary: Durable State, Transaction, and Consistency Ownership(database boundary 负责持久化状态、事务、索引、一致性和并发控制,它决定了数据是否被保存、隔离和可恢复)
- 3.5 CDN Boundary: Global Distribution and Cache-Based Response(CDN boundary 负责把静态资源、缓存响应、边缘规则和全球分发能力放到离用户更近的位置,但也引入失效、刷新和个性化缓存问题)
- 3.6 Build-Time Boundary: Static Output, Bundle Graph, and Environment Capture(build-time boundary 会决定哪些内容提前生成、哪些代码被打进 client bundle、哪些逻辑输出为 server bundle 或 edge bundle)
- 3.7 Boundary Crossing as the Source of Complexity(现代 Web 中最容易出错的地方往往是状态、权限、缓存、数据和错误跨越 browser、server、edge、database、CDN、build time 时产生的语义错位)
Chapter 4: Request, Response, Navigation, and Runtime State
- 4.1 Request as a Bundle of Intent and Context(request 同时携带 URL、method、headers、cookies、body、credentials、locale、cache state 和用户操作意图)
- 4.2 Response as More Than Returned Data(response 可以是 HTML、JSON、stream、redirect、error、asset、cache validation result)
- 4.3 Navigation Request vs Data Request(navigation request 通常创建或替换 document,而 data request 通常在已有页面中更新局部状态;现代框架会把两者融合、拆分或重新包装)
- 4.4 Runtime State Exists in Many Places at Once(状态可能同时存在于 URL、DOM、component state、browser storage、cookie、server session、database 和 cache)
- 4.5 State Ownership Determines Update Responsibility(分析一个状态由谁拥有,决定了谁负责更新、失效、同步、恢复和向用户展示错误)
- 4.6 Navigation Changes State, Execution Context, and Resource Lifetime(一次导航会改变 document、history entry、scroll/focus、network request、resource cache 和 JavaScript runtime 生命周期)
- 4.7 Runtime State Failure Creates User-Visible Bugs(状态位置判断错误会导致 stale UI、重复提交、登录丢失、hydration mismatch、缓存错乱、回退异常、跨标签页不一致等用户可见问题)
Chapter 5: How Frameworks Package System Boundaries
- 5.1 UI Frameworks Package Component, State, and DOM Update Boundaries(React、Vue、Svelte、Solid 等 UI framework 主要封装组件拆分、状态变化、事件响应、DOM 更新和交互反馈)
- 5.2 Full-Stack Frameworks Package Routing, Rendering, Data, and Mutation Boundaries(Next.js、Remix、SvelteKit 等框架把 route、loader/action、server rendering、client hydration 和 cache policy 打包成统一开发模型)
- 5.3 Server Frameworks Package Request, Middleware, and Response Boundaries(Express、Hono、Fastify、Nitro 等框架组织 request parsing、middleware chain、routing、response generation 和 error handling)
- 5.4 API and RPC Tools Package Client-Server Contract Boundaries(REST、GraphQL、tRPC、OpenAPI 等工具把输入输出 schema、序列化、错误形状和权限入口变成 contract)
- 5.5 Data Tools Package Persistence and Query Boundaries(ORM、query builder、database client、migration tool 和 query cache 决定数据访问、事务、类型和一致性边界)
- 5.6 Build Tools Package Source Transformation and Output Boundaries(Vite、Webpack、Turbopack、esbuild 等工具把源码图转换为 client bundle、server bundle、asset manifest 和 sourcemap)
- 5.7 Hosting Platforms Package Runtime, Cache, and Deployment Boundaries(Vercel、Netlify、Cloudflare、AWS 等平台把 runtime、region、edge、cache、env、logs 和 rollback 组合成部署边界)
- 5.8 Framework Comparison Must Become Boundary Comparison(比较框架需要检查它封装哪些边界、隐藏哪些成本、暴露哪些逃生口、限制哪些运行时能力,以及失败时是否可观察和可恢复)
Part 2: Web Standards, Compatibility, and Platform Contracts
Chapter 6: The Web as a Standardized, Multi-Vendor Platform
- 6.1 Web as a Structured System(Web 是由标准、浏览器实现、服务器实现、工具链和开发者实践共同形成的平台)
- 6.2 Standards Define Contracts, Browsers Define Reality(标准规定能力和语义边界,但开发者最终面对的是浏览器实现、兼容性差异、性能特征和平台限制)
- 6.3 Multi-Vendor Pressure Shapes Web Architecture(不同浏览器厂商、设备平台、操作系统、安全策略和商业需求会共同影响 Web API 的可用性、默认行为和演化速度)
- 6.4 The Web Must Preserve Old Content While Enabling New Capabilities(Web 的长期兼容性要求保留旧页面行为,同时持续加入新能力)
- 6.5 Platform Contracts Are More Stable Than Framework Abstractions(框架会快速变化,但 URL、HTML、HTTP、DOM、CSS、ECMAScript、Fetch、cookie、cache 等平台契约会长期存在,是分析 Web 系统的更稳定基础)
- 6.6 Engineering Consequence: Build on the Platform Before the Framework(分析现代 Web 时应先分析平台契约,再分析框架如何封装这些契约,否则容易把框架术语误认为 Web 本体)
Chapter 7: WHATWG, W3C, TC39, IETF, and the Standards Stack
- 7.1 WHATWG and the Living Web Platform(WHATWG 维护 HTML、DOM、Fetch、Streams 等核心 Web 平台标准,这些标准定义了浏览器文档、请求、流式数据和脚本访问边界)
- 7.2 W3C and the Broader Web Ecosystem(W3C 负责许多 Web 相关规范、工作组和可访问性标准,影响 CSS、Web API、语义结构、国际化和无障碍等平台层面)
- 7.3 TC39 and ECMAScript Language Evolution(TC39 负责 ECMAScript 语言规范,定义 JavaScript 的语法、语义、内建对象和语言级行为,但通过明确边界定义浏览器 I/O 能力)
- 7.4 IETF and the Protocol Layer of the Web(IETF 负责 HTTP、TLS、QUIC 等网络协议标准,它们决定浏览器、服务器、代理、CDN 之间如何交换请求、响应、连接状态和缓存语义)
- 7.5 Standards Organizations Form Different Layers of the Same System(不同标准组织是分别定义语言层、文档层、网络层、可访问性层、安全层和平台 API 层)
- 7.6 Reading Standards as Boundary Documents(阅读 Web 标准时,应检查它规定了哪个对象、哪个状态、哪个生命周期、哪个安全检查和哪个错误路径)
Chapter 8: HTML, DOM, CSS, ECMAScript, Fetch, and HTTP as Layered Contracts
- 8.1 HTML Defines Document Structure and Browser Parsing Semantics(HTML 定义标签集合、文档结构、解析规则、head/body 语义,以及脚本和资源如何影响 document 构建)
- 8.2 DOM Defines the Object Boundary Between Document and Script(DOM 把文档变成可被 JavaScript 访问和修改的对象树,同时也定义 mutation、event、node、element 等浏览器运行时边界)
- 8.3 CSS Defines Visual Computation and Layout Constraints(CSS 是浏览器计算视觉结构、布局关系、层叠优先级、响应式条件和渲染成本的重要输入)
- 8.4 ECMAScript Defines the Language(ECMAScript 规定语法、类型、对象模型、module、promise、iterator 和语言级执行语义)
- 8.5 Fetch Defines Request Semantics and Security Interaction(Fetch 连接 JavaScript、HTTP、CORS、credential、redirect、stream、Service Worker 和 browser security)
- 8.6 HTTP Defines Transfer Semantics Across Browser, Server, Proxy, and CDN(HTTP 规定 method、status、header、body、cache、content negotiation、redirect 等传输语义)
- 8.7 Layered Standards Create Emergent Web Behavior(现代 Web 行为是 HTML、DOM、CSS、ECMAScript、Fetch、HTTP、安全策略和浏览器实现叠加后的结果)
Chapter 9: Compatibility, Interoperability, and the Cost of a Living Platform
- 9.1 Compatibility Is a Core Web Architecture Constraint(Web 平台长期保留旧页面、旧 API、旧行为和历史错误的兼容边界)
- 9.2 Interoperability Is More Important Than Specification Beauty(一个标准设计得再干净,如果不同浏览器行为不一致,开发者仍然会面对真实系统复杂性;互操作性是 Web 能成为平台的关键)
- 9.3 Browser Differences Become Engineering Decisions(不同浏览器对 API、CSS 特性、性能优化、安全策略、媒体能力和 WebGPU 支持的差异,会直接影响技术选型和降级策略)
- 9.4 Polyfill, Transpilation, and Feature Detection Are Compatibility Tools(polyfill、transpile、feature detection、fallback 是应用跨越标准能力与真实浏览器实现差距的工程手段)
- 9.5 Living Standards Reduce Version Freezing but Increase Continuous Change(Living Standard 模型让 Web 能持续演化,但也要求开发者持续关注浏览器支持、行为变化、弃用策略和安全默认值调整)
- 9.6 Compatibility Debt Shapes Framework and Toolchain Design(框架和构建工具会隐藏兼容性复杂度,例如自动转译、注入 polyfill、处理 CSS prefix 和生成不同 bundle)
Chapter 10: Progressive Enhancement as an Architectural Principle
- 10.1 Progressive Enhancement Starts from Native Web Capabilities(渐进增强的核心是先依赖 HTML、link、form、URL、HTTP、语义结构等原生能力建立最基本可用路径)
- 10.2 Enhancement Adds Capability While Preserving the Base Path(增强层可以加入客户端路由、局部更新、动画、离线、实时协作和乐观 UI,同时保持基础访问路径的低复杂度)
- 10.3 Failure Tolerance Is a System Property(当 JavaScript 加载失败、网络变慢、缓存失效、浏览器能力不足或 hydration 延迟时,渐进增强能让系统仍然保留部分可用性)
- 10.4 Accessibility, SEO, Forms, and Navigation Share the Same Foundation(语义 HTML、可访问结构、可爬取内容、原生表单和 URL 导航看似属于不同主题,但它们都依赖 Web 平台的基础契约)
- 10.5 Modern Full-Stack Frameworks Rediscover Platform Primitives(现代框架重新重视 form、server action、server rendering、streaming、progressive enhancement)
- 10.6 Progressive Enhancement Is a Constraint on Architecture(渐进增强是一种架构约束:系统应该清楚哪些能力是基础路径,哪些能力是增强路径)
Chapter 11: Browser Baseline and Compatibility Boundaries
- 11.1 Baseline Thinking Turns Browser Support into an Architecture Decision(Browser support 同时决定能否使用某个 API、语法、CSS 特性、媒体能力或安全策略的架构边界)
- 11.2 Feature Detection Is Safer Than Assuming User-Agent Identity(通过运行时 API 和特性检测选择执行路径,降低 user-agent 假设带来的兼容风险)
- 11.3 Polyfill Extends Surface Behavior Within Platform Limits(说明 polyfill 能模拟 API 表面行为的范围,以及原生能力、安全模型和性能边界)
- 11.4 Transpilation Moves Language Compatibility into Build Time(transpilation 把新语法、新语言特性和部分平台差异提前转换为旧环境可执行形式,但也会增加 bundle、helper、source map 和调试复杂度)
- 11.5 Compatibility Targets Affect Bundle, Runtime, and User Experience(支持更老浏览器通常意味着更多转译、更大 bundle、更少原生 API、更复杂 fallback,这些都会影响加载时间、可维护性和功能边界)
- 11.6 Compatibility Strategy Must Be Explicit and Testable(兼容策略需要明确支持范围、降级路径、测试矩阵、feature detection 点和能力缺失时的用户体验)
Part 3: URL, HTTP, Network, and Resource Delivery
Chapter 12: URL as Address, State, Capability, and Routing Input
- 12.1 URL as the Stable Public Interface of the Web(URL 同时资源地址,也是 Web 系统最稳定的公共接口;它可以被收藏、分享、缓存、爬取、重放,并成为浏览器、服务器、CDN 和框架共同分析的入口)
- 12.2 Scheme, Host, Path, Query, and Fragment as System Boundaries(scheme 决定协议和安全上下文,host 决定 origin 和路由入口,path 影响资源定位,query 承载可分享状态,fragment 主要停留在客户端导航和文档定位层)
- 12.3 URL and Origin: Address Becomes Security Boundary(URL 中的 scheme、host、port 会共同参与 origin 判断,使 URL 同时决定访问位置、脚本、cookie、storage、CORS 和权限安全边界)
- 12.4 URL as Routing Input for Browser, Server, CDN, and Framework(同一个 URL 会被浏览器用于导航,被 CDN 用于缓存和转发,被服务器用于 request routing)
- 12.5 Query String as Shareable Application State(query string 可以表达分页、过滤、搜索、排序、语言、实验分组等状态;它让应用状态可复制、可分享、可缓存,但也带来隐私、长度和缓存键复杂度问题)
- 12.6 URL Design Affects Cache, SEO, Navigation, and API Semantics(URL 设计会影响缓存命中、搜索索引、用户可分析性、API 演化和路由稳定性;糟糕的 URL 设计会把架构复杂度暴露到整个系统)
Chapter 13: DNS, TCP, TLS, QUIC, and Connection Establishment
- 13.1 From URL to Connection: The Hidden Cost Before HTTP(浏览器发起 HTTP 请求前,通常需要完成 DNS 解析、连接建立、TLS 握手和协议协商,这些步骤会直接影响首屏延迟和资源加载速度)
- 13.2 DNS Resolution and Address Discovery(DNS 把域名解析为可连接地址,同时也会受到本地缓存、递归解析、CDN 调度、DNS prefetch 和网络环境的影响)
- 13.3 TCP Connection and Transport-Level Latency(在基于 TCP 的 HTTP/1.1 和 HTTP/2 中,连接建立、拥塞控制、丢包重传和队头阻塞都会影响资源交付表现)
- 13.4 TLS Handshake, HTTPS, and Trust Establishment(TLS 同时加密传输,也建立服务器身份、证书链、密钥协商和安全上下文)
- 13.5 QUIC and HTTP/3 Change the Transport Assumption(HTTP/3 基于 QUIC 承担传输层职责,改变连接恢复、多路复用、丢包影响和移动网络切换时的传输行为,同时保留 HTTP 的高层语义)
- 13.6 Preconnect and DNS Prefetch as Early Boundary Preparation(
dns-prefetch、preconnect等 resource hints 可以提前准备 DNS 或连接,降低后续请求延迟,但错误使用也可能浪费连接资源和电量)
Chapter 14: HTTP Request and Response Semantics
- 14.1 HTTP Message as a Structured Interaction Unit(HTTP message 由 method、URL、status、headers、body 等部分组成,它是浏览器、服务器、代理和缓存共同分析的交互结构)
- 14.2 Method Semantics and Operation Intent(GET、POST、PUT、PATCH、DELETE 等 method 表达不同操作意图;安全性、幂等性和可缓存性会影响 API 设计、重试策略和中间层行为)
- 14.3 Status Codes as System-Level Control Signals(2xx、3xx、4xx、5xx 是跨层控制信号,会影响重定向、缓存、浏览器行为、客户端状态机、用户反馈和故障恢复路径)
- 14.4 Headers as Cross-Layer Metadata(headers 让浏览器、服务器、CDN、proxy、cache、安全策略和内容协商共享控制信息)
- 14.5 Body as Representation, Payload, Stream, or Mutation Input(body 可以是 HTML、JSON、form data、binary、stream、file upload 或 mutation payload)
- 14.6 Request Context Determines Server Meaning(同一 endpoint 会因为 cookie、session、Authorization、locale、origin、method 和 body 产生不同服务端语义)
Chapter 15: HTTP 1.1, HTTP 2, HTTP 3, and Multiplexed Resource Loading
- 15.1 HTTP/1.1 and the Cost of Many Small Resources(HTTP/1.1 下连接数量、队头阻塞、重复 header、串行请求等问题,会让大量小资源加载变得昂贵)
- 15.2 HTTP/2 Keeps HTTP Semantics but Changes Framing and Multiplexing(HTTP/2 保留 method、status、headers、URI 等高层语义)
- 15.3 HTTP/3 Keeps HTTP Semantics but Moves Transport to QUIC(HTTP/3 继续复用 HTTP 语义,但基于 QUIC 管理连接和多路复用,减少 TCP 层丢包导致的跨 stream 阻塞,并改善部分移动网络场景)
- 15.4 Multiplexing Changes the Bundling Tradeoff(多路复用降低多个资源并发加载的成本,现代代码拆分需要同时考虑协议、缓存、优先级、解析成本和执行成本)
- 15.5 Protocol Evolution Still Leaves Resource Dependencies(说明 HTTP/2 和 HTTP/3 改善传输后,HTML、CSS、JS、font、image 和 data request 之间仍会形成首屏依赖链)
- 15.6 Framework Output Must Be Evaluated Under Real Protocol Behavior(现代框架生成的 chunk、preload、module graph、streaming response 和 server output)
Chapter 16: HTTP Headers Cookies and Cache Semantics
- 16.1 Headers as the Control Plane of HTTP(HTTP headers 是浏览器、服务器、代理、CDN、缓存和安全策略的控制平面,很多 Web 行为是由 header 决定)
- 16.2 Cookie as Request-Bound State(cookie 会自动跟随请求发送,因此它既能承载 session,也会影响缓存、隐私、CSRF 风险、跨站策略和个性化响应)
- 16.3 Cache-Control and Conditional Requests(Cache-Control、ETag、Last-Modified、If-None-Match、If-Modified-Since 共同决定缓存复用和重新验证)
- 16.4 Vary and the Shape of Cache Keys(
Vary会把 header 参与缓存键计算,使 language、encoding、user agent、authorization、cookie 等维度影响缓存命中) - 16.5 Content Negotiation and Representation Selection(Accept、Accept-Language、Accept-Encoding 等 header 让同一资源可以根据客户端能力、语言和编码偏好返回不同 representation)
- 16.6 Header Mistakes Become System Bugs(错误的 cache header、cookie attribute、content type、security header 或 Vary 配置)
Chapter 17: Resource Discovery, Preload, Prefetch, Priority, and Critical Path
- 17.1 Resource Discovery Starts from HTML and Continues Through Runtime Requests(追踪 HTML 解析、CSS 引用、JavaScript 动态加载、module graph 和 framework manifest 如何共同产生资源请求)
- 17.2 Preload Scanner and Critical Resource Discovery(浏览器会尝试提前发现关键资源,减少 parser 阻塞造成的空闲等待;但关键的资源仍取决于页面结构、CSS、JS 执行和渲染路径)
- 17.3 Preload, Prefetch, Preconnect, and DNS Prefetch Have Different Semantics(
preload用于当前页面关键资源,prefetch偏向未来导航,preconnect准备连接,dns-prefetch提前解析域名) - 17.4 Priority Is a Browser Scheduling Decision(开发者可以通过 hints 影响资源优先级,但浏览器仍会根据资源类型、渲染阻塞关系、viewport、网络状态和内部调度策略做最终决策)
- 17.5 Frameworks Generate Resource Hints but Cannot Guarantee Correct Critical Path(框架可以自动生成 preload、modulepreload、prefetch 或 manifest)
- 17.6 Incorrect Hints Can Harm Performance(过度 preload、错误 prefetch、无意义 preconnect 或过多高优先级资源会占用带宽、连接和浏览器调度资源,反而拖慢关键路径)
Chapter 18: Compression, Streaming, Incremental Delivery, and Progressive Response
- 18.1 Compression Reduces Transfer Size but Adds Processing Cost(gzip、Brotli、zstd 等压缩可以减少传输体积,但也带来压缩/解压 CPU 成本,并受内容类型、缓存策略和 CDN 配置影响)
- 18.2 Streaming Turns Response into a Progressive Process(streaming response 让服务器、代理、浏览器逐步处理数据,改善首字节、首屏和渐进呈现机会)
- 18.3 Streaming HTML Changes Server Rendering Semantics(SSR streaming 允许先发送 shell、layout、fallback 或部分内容,再逐步补充数据驱动片段,让 HTML 生成和用户可见输出形成分阶段过程)
- 18.4 Incremental Delivery Depends on Runtime, Proxy, CDN, and Browser Cooperation(即使应用层使用 streaming,如果 serverless runtime、CDN、proxy、compression buffer 或浏览器处理方式不支持)
- 18.5 Progressive Response Requires Error and Fallback Design(页面部分内容已经发送后,后续错误需要走 fallback、error boundary、stream abort 或客户端恢复路径)
- 18.6 Resource Delivery Is an Architecture Problem(资源交付决定首屏、交互、缓存、一致性、错误恢复和部署策略;它是现代 Web 架构的核心路径)
Part 4: Browser Engine Process Model, Navigation Ownership, and Page Lifecycle
Chapter 19: Browser as a Multi-Process Application Runtime
- 19.1 Browser Is an Application Runtime(现代浏览器包含进程管理、网络加载、脚本执行、渲染调度、安全隔离、存储管理和用户交互)
- 19.2 Browser Process Owns Global Coordination(browser process 通常负责窗口、标签页、导航调度、权限提示、下载、地址栏、进程管理和部分全局状态,是浏览器级控制面的核心)
- 19.3 Renderer Process Owns Document Execution(renderer process 负责具体页面或 frame 的 HTML、CSS、JavaScript、DOM、layout 和部分渲染相关工作)
- 19.4 GPU and Network Processes Separate Specialized Responsibilities(GPU process 和 network process 把图形合成、GPU 访问、网络请求和资源加载从 renderer 中拆出,改善隔离、稳定性和资源控制)
- 19.5 Process Boundaries Affect Security, Memory, and Crash Behavior(多进程模型提升隔离能力,但也增加内存占用、跨进程通信成本和进程生命周期复杂度;页面崩溃、GPU reset、网络失败都会表现为不同类型的用户可见问题)
- 19.6 Web App Architecture Must Respect Browser Runtime Boundaries(分析浏览器多进程模型、API 权限限制、跨 origin 隔离和 heavy JS 对页面响应的影响)
Chapter 20: Browser Process, Renderer Process, GPU Process, and Network Process
- 20.1 Browser Process as User Interface and Navigation Owner(browser process 管理浏览器 UI、地址栏、标签页、导航入口、权限提示、下载流程、进程分配和跨页面状态,是用户操作进入 Web 系统的第一层控制者)
- 20.2 Renderer Process as Page Execution Boundary(renderer process 是文档、脚本和页面级事件循环的执行边界)
- 20.3 GPU Process as Compositing and Hardware Access Boundary(GPU process 管理 GPU 相关资源和图形命令边界,使页面渲染、compositing、Canvas、WebGL、WebGPU 等能力可以在更受控的位置访问硬件)
- 20.4 Network Process as Resource Loading Boundary(network process 负责请求调度、连接复用、缓存交互、cookie、CORS、代理、证书验证和资源响应,是浏览器与网络世界之间的重要执行边界)
- 20.5 IPC Connects Browser Subsystems into One User Experience(浏览器内部不同进程通过 IPC 协作;一次点击、导航、fetch、渲染或权限请求,往往会穿过多个进程边界才能完成)
- 20.6 Process Separation Explains Many Browser Failure Modes(页面卡顿、renderer crash、GPU crash、网络超时、权限弹窗异常、跨站 iframe 隔离问题,核心上往往对应不同进程或 IPC 路径上的失败)
Chapter 21: Frame, Tab, Site Instance, and Isolation Boundary
- 21.1 Tab Is a User Interface Unit(用户看到的是 tab,但浏览器内部可能为不同 site、frame 或 origin 分配不同进程;tab 与 process 需要区分一一对应关系)
- 21.2 Frame Tree Defines the Document Embedding Structure(一个页面可能包含 main frame 和多个 iframe;frame tree 决定文档嵌套关系、脚本访问限制、导航归属和渲染组合方式)
- 21.3 Site Instance Represents Isolation and Process Assignment(site instance 用于表达某个站点或相关浏览上下文的隔离边界,影响 renderer process 选择、跨站 iframe 处理和安全防护)
- 21.4 Cross-Origin Frames Create Security and Communication Boundaries(跨 origin frame 通过 postMessage、权限策略、sandbox、COOP/COEP 等机制建立受控通信)
- 21.5 Out-of-Process iframe Changes the Cost of Embedding(当 iframe 被放到独立进程中时,安全隔离更强,但也引入更多 IPC、compositing 协调和生命周期管理成本)
- 21.6 Isolation Boundary Determines What a Page Can Observe and Control(分析 frame、tab、site instance 和 origin 的关系)
Chapter 22: Navigation Ownership from URL to Document Commit
- 22.1 Navigation Begins Before the Document Exists(用户输入 URL、点击链接、调用 history API 或触发表单提交时,浏览器先建立导航意图;此时新 document 可能还没有创建)
- 22.2 Browser Process Coordinates Navigation Decision(browser process 负责判断这次导航属于新文档导航、同文档导航、下载、外部协议、重定向还是历史恢复)
- 22.3 Navigation Request Carries More Than a URL(navigation request 会携带 referrer、history state、redirect mode、credentials、frame target、user activation 和 policy 判断输入)
- 22.4 Response Commit Creates the New Document Boundary(当响应被确认用于创建页面后,浏览器会 commit navigation,选择或创建 renderer、建立 document、更新 history)
- 22.5 Same-Document Navigation Changes URL and App State Within One Document(说明 hash、history.pushState 和 SPA navigation 如何改变 URL、history、scroll、focus 和应用状态)
- 22.6 Navigation Ownership Explains Framework Routing Boundaries(现代框架的 client routing、server routing、redirect、loader、action 都建立在浏览器导航模型之上)
Chapter 23: Redirect, Response Commit, History Entry, and BFCache
- 23.1 Redirect Changes the Navigation Path Before Commit(redirect 会在 document commit 之前改变目标 URL、请求上下文、缓存路径和安全判断)
- 23.2 Response Commit Is the Point Where Navigation Becomes a Page(commit 之前浏览器仍可能改道、取消、下载或报错;commit 之后新 document 生命周期开始,旧页面可能卸载、进入 BFCache 或被销毁)
- 23.3 History Entry Stores More Than URL Text(history entry 会保存 URL、state object、scroll/focus、BFCache eligibility、document lifecycle 和 restoration behavior)
- 23.4 BFCache Preserves a Frozen Page Instead of Rebuilding It(back/forward cache 会把符合条件的页面冻结保存,用户前进后退时可以快速恢复,同时减少重新请求、重新解析和重新执行脚本的成本)
- 23.5 BFCache Eligibility Is Affected by Page Behavior(unload handler、某些资源状态、跨进程关系、权限或浏览器策略可能让页面无法进入 BFCache,从而影响返回速度和状态恢复)
- 23.6 Frameworks Must Respect Browser History and BFCache Semantics(framework router 需要处理 popstate、scroll restoration、BFCache restore、form resubmission 和 data cache freshness)
Chapter 24: SPA Navigation vs Document Navigation
- 24.1 Document Navigation Replaces the Document Execution World(传统 document navigation 会让浏览器加载新响应、创建新 document、重新解析 HTML、建立新的 JS execution context)
- 24.2 SPA Navigation Reuses the Existing Document(SPA navigation 通常通过 History API 和 JavaScript 更新 URL、组件树、数据状态和局部 UI)
- 24.3 Reusing the Document Preserves Power and Risk(复用 document 可以提升交互连续性、减少完整重载和保留内存状态,但也容易造成内存泄漏、过期状态、滚动异常、焦点错误和长期运行性能下降)
- 24.4 Server Routing and Client Routing Must Agree on URL Meaning(如果服务端、CDN、静态托管和客户端 router 对同一个 URL 的分析不一致,就会出现刷新 404、深链接失效、SEO 异常或 hydration mismatch)
- 24.5 Navigation Data Loading Becomes Application Responsibility in SPA(SPA 需要自己管理 route data、loading、abort、race control、cache freshness、error boundary 和 retry path)
- 24.6 Modern Frameworks Blend Document Navigation and SPA Navigation(现代框架会把 document navigation、client transition、server redirect、loader/action、streaming 和 hydration 组合成混合导航路径)
Chapter 25: Page Lifecycle, Visibility, Freeze, Resume, and Recovery Paths
- 25.1 Page Lifecycle Is a Runtime State Machine(页面会在 active、hidden、frozen、BFCache preserved、discarded、reloaded 等状态间迁移)
- 25.2 Visibility Changes Affect Scheduling and Resource Use(当页面进入后台或不可见时,浏览器可能降低 timer 频率、暂停渲染、限制资源使用或改变网络行为,影响实时应用、音视频、数据刷新和后台任务)
- 25.3 Freeze and Resume Preserve State but Pause Execution(页面冻结时内存状态可能保留,但 JavaScript execution、timer、network callback 和 rendering 会受到限制)
- 25.4 Pagehide, Pageshow, and BFCache Restoration Need Different Handling(
pagehide、pageshow、visibilitychange等事件帮助应用区分正常卸载、进入 BFCache、从 BFCache 恢复和普通重新加载) - 25.5 Discard and Reload Break the Illusion of Continuous Runtime(浏览器可能因为内存压力丢弃后台页面,用户返回时页面重新加载;应用需要把 JS runtime 当作可中断状态)
- 25.6 Recovery Path Is Part of Application Architecture(恢复路径需要重新验证 session、刷新数据、恢复 scroll/focus、重连 realtime channel、处理 pending mutation 和重建 UI 状态)
Part 5: Browser Loading, Document Construction, Rendering, and Compositing Pipeline
Chapter 26: Browser Network Loading and Resource Scheduling
- 26.1 Resource Loading Begins Before Rendering Begins(浏览器在 document 完整构建之前就会开始发现、请求和调度资源)
- 26.2 Network Loading Is Shared by Navigation, Subresources, Fetch, and Workers(浏览器网络加载同时服务页面导航、CSS/JS/image/font 子资源、
fetch请求、worker 脚本和 service worker 拦截路径) - 26.3 Resource Type Influences Priority and Blocking Behavior(CSS、classic script、module script、font、image、video、preload resource 的优先级和阻塞语义不同)
- 26.4 Browser Scheduling Balances Critical Path and Fairness(浏览器需要在关键渲染资源、后台资源、未来导航资源和应用发起的数据请求之间分配网络和处理资源,开发者的 hint 只是调度输入之一)
- 26.5 Cache Lookup Happens Before Network Fetch(浏览器发起请求前通常会先检查 memory cache、disk cache、HTTP cache、service worker 和 cache policy)
- 26.6 Loading Failure Propagates into Rendering, Script, and User Experience(资源加载失败可能导致 CSS 缺失、脚本未执行、font fallback、图片占位、hydration 失败、module graph 中断和用户可见布局异常)
Chapter 27: HTML Tokenization, Parsing, and DOM Construction
- 27.1 HTML Response Becomes Tokens Before It Becomes a Tree(浏览器接收到 HTML 字节流后,需要经过编码识别、tokenization 和 tree construction,才能把文本响应变成可操作的 document 结构)
- 27.2 DOM Construction Is Incremental and Error-Tolerant(HTML parser 会边接收边构建 DOM,并通过错误恢复兼容大量历史页面)
- 27.3 Parser State Determines Where New Nodes Are Inserted(同样的 token 在不同 insertion mode 下可能产生不同 DOM 结构)
- 27.4 Streaming HTML Allows the Document to Start Before the Server Finishes(浏览器不必等完整 HTML 下载完才开始解析;streaming HTML 能让 document construction 和 network delivery 重叠)
- 27.5 DOM Construction Is the First Runtime Shape of the Page(DOM 是浏览器根据 HTML 解析规则构造出的运行时对象树;后续 CSS、JavaScript、accessibility、event 和 rendering 都依赖它)
Chapter 28: Parser Blocking, Script Execution, and Streaming HTML
- 28.1 Classic Scripts Can Stop the Parser(普通同步 script 可能阻塞 HTML parser,因为脚本可以读取或修改已构建的 DOM,浏览器必须在继续解析前执行它以保持语义正确)
- 28.2 CSS Can Indirectly Block Script Execution(脚本可能依赖已经计算好的样式信息,因此渲染阻塞 CSS 可能间接推迟脚本执行,进而影响 DOM construction 和首屏时序)
- 28.3
async,defer, and Module Scripts Change Execution Ordering(async、defer和 module script 通过不同方式改变下载、解析、执行和 DOMContentLoaded 的关系) - 28.4 Streaming HTML and Suspense-Like Output Require Boundary Awareness(服务器流式发送 HTML 时,fallback、partial shell、script ordering、hydration marker 和 error boundary 都会参与页面构建)
- 28.5 Parser Blocking Is a Semantics Problem Before It Is a Performance Problem(parser blocking 的根源是 Web 允许脚本在解析过程中影响 document;性能优化必须先尊重这个语义)
- 28.6 Script Loading Mistakes Create Startup and Hydration Failures(错误的脚本加载顺序、重复执行、过早访问 DOM、延迟过度或 module graph 中断,都会造成交互不可用、hydration mismatch 或页面启动卡顿)
Chapter 29: CSS Parsing, CSSOM Construction, and Style Input
- 29.1 CSS Is Parsed into a Style Rule System(CSS 文件、
style元素和 inline style 会被解析为浏览器可计算的规则集合,它们是 style calculation 的输入) - 29.2 CSSOM Exposes Stylesheets to JavaScript and the Engine(CSSOM 既服务浏览器内部样式计算,也允许 JavaScript 读取和修改部分样式表结构;这让样式成为运行时可变状态)
- 29.3 Stylesheets Can Block Rendering Because Layout Needs Style(浏览器必须知道元素的计算样式才能进行布局和绘制,因此关键 CSS 通常会阻塞首次渲染,CSS 加载路径直接影响首屏)
- 29.4 Dynamic Style Changes Trigger Invalidation(class、attribute、inline style、CSS variable、media condition 改变后,浏览器需要判断哪些元素重新计算样式)
- 29.5 CSS Imports, Fonts, and Media Conditions Affect Style Readiness(CSS import、font loading、media query、blocking stylesheet、preload 和 fallback font 会改变 style readiness)
- 29.6 CSSOM Is the Boundary Between Author Styles and Engine Computation(开发者写的 CSS 需要经过解析、层叠、继承、计算值和布局约束处理,才会影响屏幕输出)
Chapter 30: Style Calculation and Render Tree Construction
- 30.1 Style Calculation Resolves Competing Rules into Computed Values(cascade、specificity、inheritance、custom property、initial/computed/used value 会共同生成 computed style)
- 30.2 DOM Tree and Visual Tree Can Diverge(display、pseudo element、anonymous box、shadow DOM、slot 会让 DOM tree 和 visual tree 形成不同结构)
- 30.3 Render Tree Construction Filters and Transforms Document Structure(不可见节点、非视觉节点、伪元素、文本节点和布局相关匿名结构会让 render tree 与 DOM tree 存在差异)
- 30.4 Style Invalidation Determines How Much Work Must Be Recomputed(一次 class 改动、attribute 改动或 CSS variable 改动可能只影响局部,也可能导致大范围 style recalculation;失效范围是性能关键)
- 30.5 Framework DOM Updates Eventually Become Style Work(无论 UI 框架如何抽象组件和状态,最终 DOM mutation 都会进入浏览器 style calculation 和 render tree 更新路径)
- 30.6 Style Calculation Failures Become Visual and Performance Bugs(错误的 selector 设计、过宽的 invalidation、复杂层叠、动态样式抖动和过量 CSS 规则,会导致样式错乱、首屏延迟和交互卡顿)
Chapter 31: Layout, Paint, Rasterization, and Compositing
- 31.1 Layout Computes Geometry from Style and Constraints(layout 根据 computed style、containing block、formatting context、intrinsic size 和 viewport 计算元素几何)
- 31.2 Layout Is a Dependency Graph(元素尺寸和位置常常依赖父子关系、兄弟关系、字体加载、图片尺寸、container query 和 viewport,因此 layout 可能产生复杂依赖和重复计算)
- 31.3 Paint Turns Layout Results into Drawing Instructions(paint 阶段把背景、边框、文字、阴影、图片、SVG、canvas、效果和 stacking order 转换成绘制指令)
- 31.4 Rasterization Turns Drawing Work into Pixels or Textures(rasterization 会把绘制指令转成 bitmap / tile / texture,受设备像素比、viewport、GPU/CPU 分工和内存带宽影响)
- 31.5 Compositing Combines Layers into the Final Frame(compositing 把不同 layer、tile、texture、video、canvas、transform、opacity、clip 等组合成最终帧)
- 31.6 Layout, Paint, and Composite Have Different Performance Costs(修改 width 可能触发布局,修改 background 可能触发绘制,修改 transform / opacity 可能只需合成)
Chapter 32: GPU Acceleration, Layer Promotion, and Compositor Pipeline
- 32.1 GPU Acceleration Is Mostly About Composition and Raster Work(浏览器中的 GPU 加速不意味着所有 CSS 或 DOM 都在 GPU 上运行)
- 32.2 Layer Promotion Moves Some Work Away from the Main Thread(某些元素会被提升为独立 layer,使 transform、opacity、scroll 等操作可以更高效地在 compositor pipeline 中处理)
- 32.3 Compositor Thread Can Keep Some Interactions Smooth(当主线程忙于 JavaScript、style 或 layout 时,compositor thread 仍可能维持部分滚动、动画或合成操作;主线程阻塞仍需要单独治理)
- 32.4 Layer Promotion Has Memory and Management Costs(layer promotion 会消耗 GPU memory、tile/raster resources、compositor bookkeeping,并可能引入过度分层)
- 32.5 GPU Pipeline Interacts with Canvas, Video, WebGL, and WebGPU(Canvas、video、WebGL、WebGPU 等能力会进入更直接的图形路径,但仍受浏览器调度、安全模型、资源生命周期和 compositing 约束)
- 32.6 Visual Smoothness Requires Main Thread, Compositor, and GPU Coordination(流畅渲染是 JavaScript、style、layout、paint、raster、compositing 和显示刷新共同协作的结果)
Chapter 33: Browser Cache, Resource Lifetime, and Reload Semantics
- 33.1 Browser Cache Is a Layered Resource Reuse System(memory cache、disk HTTP cache、preload cache、service worker cache 和 CDN cache 共同决定资源复用)
- 33.2 HTTP Freshness and Validation Decide Reuse Behavior(Cache-Control、Expires、ETag、Last-Modified 等机制决定资源是否新鲜、是否需要验证、是否可以直接复用)
- 33.3 Reload Modes Choose Different Resource Reuse Paths(比较普通刷新、强制刷新、清缓存刷新、history navigation、BFCache restore 和 service worker update 的资源路径)
- 33.4 Hashed Assets and Immutable Caching Change Deployment Strategy(带内容 hash 的静态资源可以长期缓存,但 HTML、manifest、server data 和 personalized response 需要更谨慎的失效策略)
- 33.5 Cache Mistakes Become Version Skew and Startup Bugs(HTML 引用旧 bundle、JS chunk 已被删除、CSS 与 JS 版本不一致、service worker 缓存旧资源)
- 33.6 Resource Lifetime Must Be Designed with Deployment and Rollback(缓存策略需要同时覆盖单次加载性能、版本发布、灰度、回滚、CDN purge、service worker 更新和用户长期会话)
Chapter 34: DevTools as the Browser Observability Surface
- 34.1 DevTools Reveals Browser Reality Behind Framework Abstractions(框架会隐藏 DOM 更新、网络请求、bundle 加载、hydration 和渲染成本,但 DevTools 能把这些抽象重新还原为浏览器实际行为)
- 34.2 Network Panel Shows Resource Timing and Request Semantics(Network panel 展示 request waterfall、priority、cache status、protocol、headers、timing 和 response body)
- 34.3 Performance Panel Shows Main Thread, Rendering, and Frame Cost(Performance panel 把 long task、style/layout/paint、composite、event、network 和 frame timing 放到同一时间线)
- 34.4 Elements and Computed Styles Expose DOM and CSS Reality(Elements panel 与 computed styles 能看到真实 DOM、CSS cascade、box model、layout、accessibility 和 event listener)
- 34.5 Memory and Coverage Expose Runtime Waste(Memory panel、heap snapshot、allocation timeline、coverage 能帮助发现内存泄漏、未使用代码、重复资源和长期 SPA 运行问题)
- 34.6 DevTools Turns Browser Internals into Engineering Evidence(浏览器调试是证明 Web 系统路径、资源生命周期、渲染成本和失败原因的工程证据)
Part 6: Document Model, HTML Semantics, Accessibility, and Public Web Discovery
Chapter 35: HTML as Semantic Document and Runtime Input
- 35.1 HTML Is Both Content Structure and Runtime Input(HTML 既是页面内容的标记格式,也是浏览器构建 DOM、发现资源、建立语义结构、触发脚本执行和形成可访问结构的输入)
- 35.2 Elements Encode Meaning Before Style and JavaScript(heading、list、button、link、form、table、landmark 等元素先提供机器可理解的语义和默认行为)
- 35.3 Attributes Shape Behavior, Accessibility, Navigation, and Security(attribute 可以改变 form behavior、resource loading、accessibility name、navigation target、安全策略和浏览器默认行为)
- 35.4 Head and Body Serve Different System Roles(
head声明 metadata、resource、policy、title、viewport、preload 等系统信息;body承载用户可见内容和交互结构) - 35.5 Semantic HTML Reduces Framework and Script Responsibility(正确的语义元素可以让浏览器、辅助技术、搜索引擎、表单机制和键盘交互自动工作,减少框架和自定义 JavaScript 需要手工补齐的行为)
- 35.6 Invalid or Non-Semantic HTML Creates Downstream System Cost(错误嵌套、滥用
div、缺少标签关联、错误控件语义和无意义结构,会把问题传递给 CSS、JS、可访问性、SEO、测试和维护层)
Chapter 36: DOM Tree, Node, Element, Attribute, and Mutation
- 36.1 DOM Is the Runtime Object Model of the Document(DOM 把 HTML document 转换成可被 JavaScript 访问、遍历、修改和监听的对象树,是文档与脚本之间的核心运行时边界)
- 36.2 Node, Element, Text, Document, and Fragment Represent Different Tree Roles(Document、Element、Text、Comment、DocumentFragment 等节点承担不同结构角色)
- 36.3 Attributes and Properties Have Reflection Boundaries(说明 HTML attribute、DOM property、初始标记、运行时状态、表单值和反射属性之间的映射关系)
- 36.4 DOM Mutation Is a System Event(DOM mutation 会触发 selector invalidation、layout work、MutationObserver、event path 和 framework reconciliation 后果)
- 36.5 Event Targets and DOM Tree Shape Define Interaction Propagation(事件捕获、冒泡、target、currentTarget、shadow boundary、delegation 等机制都依赖 DOM 树结构和事件路径)
- 36.6 Framework Virtual Trees Eventually Become Real DOM Effects(无论框架使用 virtual DOM、template compiler、signals 还是 fine-grained reactivity)
Chapter 37: Head Elements, Resource Hints, Script, Style, and Loading Influence
- 37.1 The Head Section Controls Invisible System Behavior(
head中的 title、meta、link、script、style、base 等元素会影响页面身份、资源加载、渲染启动和机器可读信息) - 37.2 Metadata Shapes Document Identity and Machine Interpretation(title、description、viewport、charset、canonical、robots、Open Graph 等 metadata 定义文档身份和机器解读方式)
- 37.3 Link Elements Connect the Document to External Resources and Relationships(
link可以声明 stylesheet、icon、manifest、canonical、preload、prefetch、preconnect 等关系) - 37.4 Script Placement Changes Parsing and Startup Behavior(script 在
head、body、defer、async、module、inline、external 等不同形态下) - 37.5 Style Placement Changes Rendering Readiness(外部样式、内联关键 CSS、异步 CSS、media 条件和字体声明会影响 render-blocking、首屏样式完整性和 layout shift 风险)
- 37.6 Resource Hints Must Match the Real Critical Path(preload、prefetch、preconnect、modulepreload 等 hint 必须匹配真实关键路径,错误 hint 会浪费带宽、连接和浏览器调度资源)
Chapter 38: Native Forms, Inputs, Constraint Validation, and Submission Semantics
- 38.1 Forms Are the Original Web Data Submission Boundary(form 是 Web 原生的 mutation 机制,它能在没有复杂客户端框架的情况下把用户输入提交给服务器,并建立浏览器、HTTP 和 server action 之间的基础路径)
- 38.2 Controls Hold User Input State Before JavaScript Reads It(input、textarea、select、button、checkbox、radio、file 等控件本身拥有值、选中、焦点、禁用、校验等状态)
- 38.3 Names, Values, Encoding, and Method Define Submission Shape(name、value、encoding type、method、action、disabled/readonly 等规则决定提交请求形态)
- 38.4 Constraint Validation Is Browser-Level User Feedback(required、pattern、min、max、type、step、自定义 validity 等机制让浏览器在提交前执行基础校验和用户反馈,服务器端验证仍承担信任边界)
- 38.5 Native Submission Has Built-In Navigation and Recovery Semantics(原生表单提交天然支持 enter 提交、浏览器历史、redirect-after-post、自动填充、密码管理器、无障碍访问和失败重试路径)
- 38.6 Enhanced Forms Should Preserve the Native Path When Possible(现代框架可以增强表单为局部更新、pending state、optimistic UI 和 server action,但应尽量保留基础提交语义和失败降级路径)
Chapter 39: Custom Elements, Shadow DOM, Template, and Encapsulation Boundary
- 39.1 Web Components Define a Native Component Boundary(Custom Elements、Shadow DOM、template 和 slot 提供了浏览器原生组件能力,允许组件拥有生命周期、封装结构和可复用标记)
- 39.2 Custom Element Lifecycle Connects Markup and Runtime Behavior(connectedCallback、disconnectedCallback、attributeChangedCallback 和 adoptedCallback 把自定义元素生命周期接入 DOM runtime)
- 39.3 Shadow DOM Creates a Scoped Tree Boundary(Shadow DOM 在普通 DOM 树之外建立封装树,改变选择器作用域、事件路径、slot 分发、样式隔离和组件内部结构可见性)
- 39.4 Template and Slot Separate Definition from Composition(
template声明惰性 DOM 结构,slot 把宿主内容投射进组件内部,连接封装和组合) - 39.5 Encapsulation Solves Some Problems and Creates Others(封装可以减少样式污染和结构泄漏,但也可能增加调试、可访问性、测试、主题定制、表单集成和框架互操作复杂度)
- 39.6 Web Components Are Platform Primitives(Web Components 提供组件边界,但通过明确边界解决路由、数据加载、全局状态、服务端渲染、缓存一致性和部署运行时问题)
Chapter 40: Accessibility Tree, Semantic Mapping, Focus, and Keyboard Navigation
- 40.1 Accessibility Is a Runtime Representation(可访问性是浏览器根据 DOM、语义元素、ARIA、状态和样式生成可被辅助技术分析的运行时结构)
- 40.2 Accessibility Tree Is Derived from DOM and Semantics(辅助技术通常是依赖 accessibility tree;错误的 HTML 语义、隐藏策略或 ARIA 使用会改变用户实际接收到的信息)
- 40.3 Role, Name, State, and Property Define Accessible Meaning(一个控件是否可分析,取决于 role、accessible name、state、property 等信息是否正确,并需要同时检查可访问树和屏幕外观)
- 40.4 Focus Is the Navigation State of Keyboard and Assistive Interaction(focus 会在 tab order、activeElement、shadow boundary、modal、assistive tech 和 keyboard event 之间传递)
- 40.5 ARIA Repairs Gaps but Cannot Replace Native Semantics(ARIA 可以补充语义或表达复杂状态,但错误使用会覆盖浏览器原生语义,甚至让可访问性变得更差)
- 40.6 Accessibility Failures Are System Failures(可访问性问题是文档语义、组件封装、事件处理、焦点管理、路由切换和测试流程共同失败的结果)
Chapter 41: Internationalization Locale and Text Semantics
- 41.1 Internationalization Begins with Text Representation and Language Metadata(国际化需要区分翻译文案那么简单,它首先依赖 Unicode、编码、
lang、文本分段、语言标注和正确的字符处理) - 41.2 Locale Changes Formatting, Sorting, Parsing, and Meaning(日期、时间、数字、货币、大小写、排序、复数、姓名、地址和单位都会受到 locale 影响,需要按用户语境处理)
- 41.3 Direction and Writing Mode Affect Layout and Interaction(LTR、RTL、vertical writing、bidirectional text 会影响布局、图标方向、滚动、输入光标、表格、导航和视觉顺序)
- 41.4 Translation Boundary Is a Product and Runtime Boundary(翻译内容可能来自 build time、server runtime、client runtime、CMS、database 或第三方系统)
- 41.5 I18N Interacts with URL, Cache, SEO, and Accessibility(语言选择可能体现在 URL、header、cookie、local storage 或用户资料中)
- 41.6 Hard-Coded Assumptions Become Globalization Bugs(写死文本方向、日期格式、字符串长度、字体、货币、姓名结构或复数规则,会导致布局破裂、含义错误、缓存错乱和用户体验失败)
Chapter 42: Crawling, Sitemap, Open Graph, Structured Data, and Public Web Discovery
- 42.1 Public Web Discovery Starts from Crawlable Documents(公开 Web 的发现依赖可访问 URL、可解析 HTML、链接关系、robots 规则、sitemap、metadata 和内容可见性)
- 42.2 Metadata Shapes How Machines Describe a Page(title、description、canonical、Open Graph、Twitter Card 和 structured data 决定搜索与社交系统如何展示页面)
- 42.3 Sitemap and Internal Links Expose Site Structure(sitemap 可以帮助搜索引擎发现 URL,内部链接则表达页面之间的关系;没有清晰链接结构的 SPA 或孤立页面更难被机器系统分析)
- 42.4 Structured Data Adds Machine-Readable Meaning(JSON-LD、Microdata、RDFa、Schema.org 等结构化数据能把页面内容表达成机器可分析的实体、属性和关系,支持更丰富的搜索和知识提取)
- 42.5 Rendering Strategy Affects Discoverability(SSR、SSG、CSR、streaming、hydration 和 robots 可访问内容会改变 crawler 能看到的信息)
- 42.6 Public Discovery Is an Architecture Boundary(SEO、metadata、sitemap、structured data、social preview 和可爬取内容属于 Web 公开性的一部分)
Part 7: CSS Cascade, Layout, Visual Formatting, and Rendering Cost
Chapter 43: Cascade, Specificity, Inheritance, and Computed Value
- 43.1 CSS Is a Constraint System(CSS 通过选择器、层叠、继承、计算值和布局约束告诉浏览器如何把文档结构转换成可视结构)
- 43.2 Cascade Resolves Competing Declarations(origin、importance、cascade layer、specificity、source order 共同决定同一属性最终声明)
- 43.3 Specificity Encodes Selector Weight(specificity 决定选择器在冲突时的权重;复杂选择器和过高权重会让样式系统难以覆盖、难以维护,也会增加大型应用中的样式治理成本)
- 43.4 Inheritance Carries Values Through the Document Tree(某些属性会沿 DOM 树继承,让字体、颜色、方向、语言相关样式自然传播;但继承也可能让组件边界、嵌套结构和主题系统出现意外影响)
- 43.5 Computed Value Is the Engine’s Resolved Style Input(computed value 是 selector、cascade、inheritance、custom property 解析后的样式输入,后续 used value、layout、paint 都依赖它)
- 43.6 CSS Custom Properties Change the Style Dependency Graph(CSS variables 让样式值可以跨作用域传播和动态改变,但也会让 style invalidation、主题切换、组件封装和运行时样式更新更复杂)
- 43.7 Cascade Strategy Is an Architecture Decision(cascade strategy 需要约束 layer、scope、naming、specificity、theme token 和 override path)
Chapter 44: Box Model, Normal Flow, Formatting Context, and Overflow
- 44.1 Every Visual Element Becomes One or More Boxes(浏览器布局是根据 display、box model、text、pseudo element、anonymous box 等规则生成参与布局的 box)
- 44.2 Box Model Defines the Local Geometry Contract(content、padding、border、margin 共同定义元素自身的几何边界;
box-sizing会改变 width/height 如何参与尺寸计算) - 44.3 Normal Flow Is the Default Layout Algorithm(在没有特殊定位和复杂布局模型介入时,block、inline、inline-block 等元素按照 normal flow 形成基础布局,这也是分析所有高级布局的起点)
- 44.4 Formatting Context Creates Local Layout Rules(BFC、IFC、flex/grid formatting context 会为内部 box 建立局部布局规则和外部交互边界)
- 44.5 Overflow Turns Geometry into Scroll and Clipping Behavior(overflow 会把几何溢出转换成 clipping、scroll container、scrollbar、hit testing 和 sticky/fixed 行为)
- 44.6 Intrinsic Size and Content Measurement Affect Layout Stability(图片、字体、文本换行、aspect ratio、min/max content 会影响 intrinsic size 和布局稳定性)
- 44.7 Box Model Errors Propagate into Rendering and Interaction Bugs(错误的尺寸假设、margin collapse、overflow clipping、滚动容器误判和 intrinsic size 缺失)
Chapter 45: Flexbox, Grid, Alignment, and Modern Layout Systems
- 45.1 Flexbox Solves One-Dimensional Distribution Problems(Flexbox 主要解决一维主轴上的空间分配、对齐、伸缩和换行问题,适合导航栏、工具条、卡片行、局部组件布局等场景)
- 45.2 Grid Solves Two-Dimensional Track and Area Problems(Grid 通过行、列、track、area、gap 和 placement 规则解决二维布局问题,更适合页面骨架、复杂面板、响应式区域和结构化内容排列)
- 45.3 Alignment Is a Cross-Model Layout Language(justify、align、place 等 alignment 规则贯穿 flex、grid、block 和绝对定位等场景,是现代 CSS 统一对齐行为的重要机制)
- 45.4 Flex and Grid Encode Layout Intent Differently(Flex 更偏内容驱动和流式分配,Grid 更偏容器驱动和空间规划;选错模型会导致复杂 hack、难以响应式适配和维护成本上升)
- 45.5 Modern Layout Systems Reduce JavaScript Layout Work(很多过去需要 JavaScript 计算尺寸、排列和响应式断点的 UI)
- 45.6 Layout Model Choice Affects Accessibility and Source Order(布局模型需要同时维护视觉顺序、DOM 顺序、键盘导航顺序、屏幕阅读顺序和可访问路径)
- 45.7 Complex Layouts Should Be Designed as Constraint Systems(复杂页面应明确容器约束、内容尺寸、断点条件、对齐规则、滚动区域和失败形态)
Chapter 46: Positioning, Containing Block, Stacking Context, and Layering
- 46.1 Positioning Changes Which Geometry Context an Element Uses(static、relative、absolute、fixed、sticky 等定位模式决定元素是否参与 normal flow)
- 46.2 Containing Block Determines Coordinate Meaning(absolute、fixed、sticky、transform、filter、contain、will-change 等规则可能改变 containing block)
- 46.3 Stacking Context Defines Paint Ordering Boundaries(stacking context 把 z-index、opacity、transform、filter、isolation、position 等规则组织成 paint order 边界)
- 46.4 Layering Problems Are Interaction Problems(modal、popover、tooltip、dropdown、toast、drawer、sticky header 等 UI 既有视觉层叠问题)
- 46.5 Fixed and Sticky Elements Depend on Scroll and Containment Context(fixed / sticky 的表现会受到 scroll container、overflow、transform、containment、viewport 和嵌套布局影响)
- 46.6 Visual Stacking Requires Event, Focus, and Accessibility Alignment(说明视觉覆盖、焦点顺序、可访问树和事件路径需要共同校准)
- 46.7 Layering Architecture Should Be Explicit in Large Apps(大型应用应该为 overlay、modal、portal、z-index scale、stacking context 和 focus management 建立清晰规则)
Chapter 47: Responsive Design, Media Query, Container Query, and Adaptive Conditions
- 47.1 Responsive Design Is an Adaptation Strategy(响应式设计的目标是让内容、布局、交互和资源在不同设备、输入方式、像素密度和网络条件下保持可用)
- 47.2 Media Queries Express Global Environment Conditions(media query 用 viewport、pointer、hover、color scheme、resolution、reduced motion 等全局条件选择样式路径)
- 47.3 Container Queries Express Local Layout Conditions(container query 让组件根据父容器或局部布局条件调整自身,降低对全局 viewport 的依赖,从而更适合可复用组件和复杂页面区域)
- 47.4 Responsive Images and Fonts Affect Layout and Loading(responsive image、srcset、sizes、font loading 和 DPR 会同时影响 resource selection、layout stability 和 visual quality)
- 47.5 Adaptive UI Must Consider Input and Interaction Mode(触摸、鼠标、键盘、屏幕阅读器、手写笔、电视遥控器、低性能设备等输入模式会改变可点击区域、hover 行为、focus 体验和导航方式)
- 47.6 Responsive Conditions Can Become State Fragmentation(统一 viewport、container、theme、locale、feature flag、user preference 和 auth state 边界)
- 47.7 Good Responsive Architecture Separates Content Priority from Layout Form(稳定的响应式架构先定义内容优先级和交互目标,再选择布局形式,再把视觉断点落实为 CSS 条件)
Chapter 48: CSS Containment, Layout Invalidation, and Layout Shift
- 48.1 Rendering Work Is Triggered by Invalidation(浏览器根据 DOM、style、layout、size、paint、scroll 等变化判断哪些区域需要重新计算或重绘)
- 48.2 Style Invalidation and Layout Invalidation Have Different Costs(修改 class、attribute、custom property 可能触发 style recalculation)
- 48.3 CSS Containment Limits the Blast Radius of Change(
contain、content-visibility等能力可以告诉浏览器某些元素的样式、布局、绘制或尺寸影响被限制在局部,从而降低大页面更新成本) - 48.4 Layout Shift Happens When Geometry Changes After Users See the Page(图片尺寸缺失、字体替换、广告注入、异步内容、hydration 结果变化、late CSS 等都会导致用户已经看到的元素位置发生移动)
- 48.5 CLS Is a User-Visible Symptom of Layout Instability(Cumulative Layout Shift 是用户感知到页面跳动、误点击和阅读中断的指标化结果)
- 48.6 Framework Rendering Can Accidentally Increase Layout Instability(framework hydration、conditional rendering、late data、client-only component 和 suspense fallback 都可能改变首屏几何)
- 48.7 Layout Stability Requires Reserving Space and Controlling Late Changes(稳定布局需要提前声明尺寸、使用 aspect-ratio、控制字体交换、预留动态内容空间,并约束首屏后的元素插入)
Chapter 49: Animation Cost Across Layout, Paint, and Composite
- 49.1 Animation Is Repeated Rendering Work(动画是在连续帧中不断触发浏览器更新;它的成本取决于每帧需要走 layout、paint 还是只走 composite)
- 49.2 Layout-Affecting Animations Are Usually Expensive(动画修改 width、height、top、left、margin、font-size 等属性时,可能触发布局计算和后续绘制,容易造成 jank 和输入延迟)
- 49.3 Paint-Affecting Animations Can Still Be Costly(背景、阴影、滤镜、边框、clip-path、复杂 SVG、文本效果等属性可能不触发布局,但会增加 paint 或 raster 成本)
- 49.4 Transform and Opacity Are Usually Compositor-Friendly(transform 和 opacity 通常可以在 compositor pipeline 中高效处理,常用于高性能动画)
- 49.5 Motion Preference and Accessibility Constrain Animation Design(动画需要尊重 prefers-reduced-motion、控制眩晕风险、处理焦点移动、交互反馈和认知负担;适配用户能力比单纯流畅更重要)
- 49.6 Animation Performance Must Be Measured in Frames and Input Responsiveness(动画需要用 frame time、long task、input delay、dropped frame、compositor activity 和 accessibility signal 评估)
- 49.7 Animation Architecture Should Separate Meaningful Feedback from Decorative Motion(系统级动画应该服务状态变化、导航过渡、用户反馈和空间关系;装饰动画需要被限制在不会破坏性能和可访问性的边界内)
Part 8: JavaScript Engine, Event Loop, Memory, and Host Runtime Coordination
Chapter 50: JavaScript Source to Execution
- 50.1 JavaScript Source as a Structured System(JavaScript 引擎先完成解析、语法结构构建、作用域分析、字节码或机器码生成等步骤,再进入实际执行)
- 50.2 Script, Module, Function, and Dynamic Code Enter Through Different Paths(classic script、module、dynamic import、eval/new Function、inline handler 会走不同解析、缓存和执行路径)
- 50.3 Lexical Environment and Scope Are Built Before Runtime Access(变量、函数、块级作用域、module binding、closure 捕获等语义需要在执行前或执行过程中建立词法环境,决定名字如何被查找和更新)
- 50.4 Execution Context Connects Code, Scope, and Runtime State(每次脚本、函数、module 或 callback 执行时,都会进入特定 execution context,携带当前代码位置、词法环境、this binding、调用栈和异常状态)
- 50.5 JavaScript Execution Depends on Host Integration(JavaScript 通过 DOM binding、event loop、Web API、worker、network、storage 和 security policy 进入 host runtime)
- 50.6 Source-Level Reasoning Can Be Misleading After Optimization(开发者看到的源码结构可能等于运行时执行形态,JIT、inline cache、函数内联、隐藏类、deoptimization 等机制会改变性能行为和调试感受)
Chapter 51: Parser, Bytecode, Baseline Compilation, and Optimizing Compilation
- 51.1 Parsing Turns Source into Engine-Usable Structure(parser 把源码转换成引擎内部结构,检查语法、建立函数边界、识别声明、记录源码位置,并为后续字节码生成和优化准备输入)
- 51.2 Bytecode Provides a Portable Internal Execution Layer(现代 JavaScript 引擎通常会先把源码转换成字节码或类似中间表示,使代码可以快速开始执行,并为 profiling 和后续优化留下统一入口)
- 51.3 Baseline Execution Prioritizes Startup and Responsiveness(baseline interpreter 或 baseline compiler 关注快速启动和较低编译成本,让代码尽早运行,把昂贵的深度优化留给后续阶段)
- 51.4 Optimizing Compilation Uses Runtime Feedback(优化编译器会利用真实运行时反馈,例如对象形状、调用目标、类型稳定性、热点路径和分支行为,生成更高效的机器码)
- 51.5 Deoptimization Is the Cost of Speculation(JavaScript 引擎常基于“当前看起来稳定”的假设进行优化,一旦对象形状、类型或调用路径发生变化,可能需要 deopt 回到较通用的执行路径)
- 51.6 Tiered Execution Explains Warmup and Performance Cliffs(同一段代码在冷启动、预热、热点优化和 deopt 后的性能可能不同;这也是某些页面首交互慢、长时间运行后变快或突然变慢的原因)
- 51.7 Engine Internals on Framework Runtime Hot Paths(定位状态更新、diff、serialization、validation、animation 或 data processing 进入热路径后的引擎成本)
Chapter 52: Call Stack, Heap, Object Allocation, and Garbage Collection
- 52.1 Call Stack Represents Active Execution(调用栈记录当前正在执行的函数、返回位置、局部状态和异常展开路径;递归过深、同步调用链过长或错误传播都会直接反映在 stack 行为中)
- 52.2 Heap Stores Long-Lived Runtime Objects(对象、数组、闭包、DOM wrapper、缓存数据、组件状态、promise、listener 等运行时结构通常位于 heap 中,并通过引用关系形成对象图)
- 52.3 Object Allocation Is Cheap Until It Becomes Continuous Pressure(短生命周期对象分配通常很快,但大量临时对象、频繁 diff、序列化、日志、immutable update 和动画中分配会增加 GC 压力)
- 52.4 Garbage Collection Reclaims Memory but Can Interrupt Work(GC 自动回收不可达对象,但标记、扫描、压缩、增量回收和主线程协调都可能造成停顿、抖动或响应性下降)
- 52.5 Memory Leaks Are Usually Retention Bugs(内存泄漏通常来自仍被引用的 listener、closure、DOM node、cache、timer、subscription、detached tree)
- 52.6 DOM and JavaScript Memory Can Retain Each Other(JS object 可以引用 DOM node,DOM listener 又可以引用 JS closure,形成跨引擎和 DOM 的保留链)
- 52.7 Memory Architecture Affects Long-Running Web Apps(SPA、dashboard、editor、realtime app、media app 可能长时间运行)
Chapter 53: Event Loop, Task Queue, Microtask Queue, and Rendering Coordination
- 53.1 Event Loop Coordinates JavaScript, Events, and Rendering Opportunities(event loop 让浏览器在单个主执行线程上协调用户事件、timer、network callback、promise continuation、DOM 更新和渲染机会)
- 53.2 Tasks Represent Larger Units of Asynchronous Work(click、keydown、timer、message、network callback、script execution 等通常以 task 形式进入调度队列)
- 53.3 Microtasks Run at Checkpoints Before Returning to the Browser(Promise reaction、queueMicrotask、MutationObserver 等 microtask 会在特定 checkpoint 被清空)
- 53.4 Microtask Starvation Can Delay Rendering and Input(如果 microtask 不断追加新的 microtask,浏览器可能迟迟无法进入渲染或处理输入,导致页面看似异步但仍然卡顿)
- 53.5 Rendering Is Coordinated with the Event Loop(样式计算、布局、绘制和合成的时机与 event loop 协调;JavaScript 长时间占用主线程会推迟渲染更新和用户反馈)
- 53.6 Different Queues Create Different Ordering Guarantees(task、microtask、animation frame、idle callback、message channel、scheduler API 等机制提供不同执行时机)
- 53.7 Framework Scheduling Is Built on Host Scheduling Constraints(React concurrent rendering、Vue scheduler、Svelte update flush 等框架调度都受 task、microtask、render opportunity 约束)
Chapter 54: Promise, Timer, Event Callback, and Asynchronous Continuation
- 54.1 Asynchronous JavaScript Is Continuation Scheduling(异步代码是把后续逻辑注册为 callback、promise continuation 或任务,在未来某个调度点继续执行)
- 54.2 Promise Resolution Schedules Microtasks Before Rendering Decisions(追踪 Promise resolve、microtask 队列、framework flush、主线程空闲和浏览器渲染时机的关系)
- 54.3 Timers Are Delay Requests(
setTimeout、setInterval表示“至少延迟一段时间后尝试调度”,实际执行会受到主线程占用、后台页面节流、嵌套 timer、浏览器策略影响) - 54.4 Event Callbacks Execute Inside Browser-Defined Interaction Paths(click、input、keydown、pointermove、scroll 等事件回调由浏览器事件系统调度)
- 54.5 Abort, Cleanup, and Cancellation Are Part of Async Architecture(异步路径必须考虑用户离开页面、请求取消、组件卸载、路由变化、重复点击、超时和资源释放,否则容易产生竞态、泄漏和 stale update)
- 54.6 Async Ordering Bugs Become State Bugs(异步结果乱序、过期请求覆盖新状态、timer 未清理、promise 未捕获、重复 callback 和 race condition 都会表现为 UI 状态错乱或用户操作失败)
Chapter 55: DOM Binding, Web API Callback, and Host Runtime Integration
- 55.1 JavaScript Engine Runs Inside Browser Host Capabilities(JS engine 执行语言语义,DOM、Fetch、timer、storage、worker、GPU 等能力来自浏览器 host)
- 55.2 DOM Bindings Bridge Native Browser Objects and JavaScript Objects(JavaScript 访问
document、element、window等对象时,实际上跨越了 JS engine 与浏览器内部对象模型之间的 binding 边界) - 55.3 Web APIs Often Start Work Outside the JavaScript Call Stack(
fetch、timer、IndexedDB、WebSocket、media、worker 等 API 调用后,工作可能在浏览器其他线程、进程、网络栈或系统服务中继续执行) - 55.4 Callback Reentry Brings Host Results Back into JavaScript(当异步工作完成后,浏览器会把结果以 task、microtask、event、message 或 stream chunk 的形式重新带回 JavaScript 执行路径)
- 55.5 Host Integration Defines Security and Capability Limits(剪贴板、相机、位置、GPU、文件系统、跨源响应等能力由浏览器权限、安全上下文和平台策略决定)
- 55.6 DOM Binding Cost Matters in Hot Paths(频繁读取 layout 信息、循环操作 DOM、跨 binding 大量访问属性、同步测量与写入交错,会把 JavaScript 性能问题转化为浏览器引擎协作成本)
Chapter 56: Long Task, Main Thread Pressure, Responsiveness, and Input Delay
- 56.1 Main Thread Is a Shared Resource(main thread 同时承担 script execution、event callback、style/layout、GC、部分 rendering 和 framework update)
- 56.2 Long Tasks Delay Input, Rendering, and Feedback(长任务会阻止浏览器及时处理点击、键盘、滚动、hover、动画和渲染更新,使用户感觉页面卡住,即使网络和服务器都很快)
- 56.3 Input Delay Is a Symptom of Scheduling Failure(用户输入到回调执行之间的延迟,通常来自主线程被脚本、layout、GC、framework update 或大量 microtask 占用)
- 56.4 Work Must Be Split Across Frames, Tasks, Workers, or Idle Time(复杂计算、列表渲染、解析、序列化、搜索、压缩和图像处理等工作需要拆分、延迟、放到 worker 或利用 idle time,否则会破坏交互响应)
- 56.5 Framework Abstractions Can Hide Main Thread Pressure(component update、diff、effect、scheduler、state library 和 dev tooling 可能把主线程成本藏在抽象之下)
- 56.6 Responsiveness Must Be Designed, Measured, and Protected(响应性是架构约束;需要在数据量、渲染范围、代码拆分、worker 使用、调度策略和性能预算中提前设计)
- 56.7 JavaScript Performance Is User-Visible When It Blocks the System Path(当 JS 阻塞 input、rendering、network callback、hydration 或 cleanup,用户会直接感到等待和卡顿)
Part 9: Web Platform APIs and Cross-Boundary Capability Paths
Chapter 57: Fetch, Request, Response, Body, and Streams
- 57.1 Fetch Is the Browser’s Programmable Request Boundary(Fetch 把 URL、method、headers、body、credentials、cache、redirect、AbortSignal 和 response stream 组成可编程请求)
- 57.2 Request Object Encodes Intent, Context, and Policy(
Request承载 URL、method、headers、body、mode、credentials、cache、redirect、referrer、signal 等信息) - 57.3 Response Object Encodes Data, Metadata, and Failure Shape(
Response承载 status、headers、body stream、type、redirected 等信息,应用需要按完整响应对象分析) - 57.4 Body and Streams Turn IO into Incremental Consumption(请求和响应 body 可以通过 stream 逐步读取或写入,使大文件、实时数据、渐进渲染、解码管线和 backpressure 成为架构问题)
- 57.5 Abort and Timeout Are Part of Request Architecture(用户切换路由、重复搜索、组件卸载、网络变慢、服务器无响应时,Fetch 必须通过 AbortController、超时策略和状态保护处理 stale update 和资源泄漏风险)
- 57.6 Fetch Failure as a Structured System(网络错误、CORS 拒绝、abort、DNS/TLS 失败和 HTTP 4xx/5xx 在 Fetch 中表现不同)
- 57.7 Fetch Is Where Client State Meets Network Reality(client state、auth、cache、CORS、abort、network failure、HTTP status 和 response parsing 都会在 Fetch path 汇合)
Chapter 58: URL, History, Navigation, Location, and Browser State
- 58.1 URL APIs Turn Address Text into Structured State(
URL、URLSearchParams等 API 让应用能结构化读取和修改 path、query、hash、origin 等信息,使 URL 成为可编程的应用状态) - 58.2 Location Represents the Current Document Address Boundary(
window.location连接当前 document、浏览器地址栏和导航行为;直接赋值、replace、reload 都会触发不同形式的浏览器级导航) - 58.3 History API Lets Applications Change URL Inside the Current Document(
pushState、replaceState、popstate让 SPA 在当前 document 中管理 URL 和 history entry) - 58.4 Navigation State Is Shared by Browser, Framework, and User(浏览器维护 history entry,框架维护 route state,用户通过返回/前进按钮操作路径;三者如果语义不一致,就会出现返回错乱、数据丢失和 UI 状态异常)
- 58.5 Search Params Are Shareable State with Cache and Privacy Costs(query 参数适合表达搜索、过滤、分页和语言等可分享状态,但也会影响 cache key、日志记录、隐私泄漏和 URL 稳定性)
- 58.6 Browser Navigation APIs Define the Boundary Between Platform and Router(框架路由并是在 History / Navigation / Location 等平台能力之上建立应用级路由语义)
Chapter 59: Cookie, Local Storage, Session Storage, IndexedDB, and Storage Lifetime
- 59.1 Browser Storage as a Structured System(cookie、localStorage、sessionStorage、IndexedDB、Cache Storage 各自拥有不同生命周期、容量、同步模型和请求参与方式)
- 59.2 Cookie Is Request-Bound State(cookie 会自动附加到匹配请求中,因此它天然参与 session、CSRF、cache key、跨站策略和服务端身份判断)
- 59.3 Web Storage Is Simple but Synchronous and Limited(localStorage / sessionStorage 使用简单,但同步 API 可能阻塞主线程,且适合轻量状态,不适合大规模结构化数据和高频读写)
- 59.4 IndexedDB Is the Browser’s Structured Client Database Boundary(IndexedDB 适合存储大量结构化对象、离线数据、索引数据和长期客户端状态,但它的异步模型、事务边界、版本升级和清理策略需要认真设计)
- 59.5 Storage Lifetime Depends on Browser Policy and User Context(存储可靠性受隐私策略、站点数据清理、存储压力、第三方上下文、无痕模式和 partitioning 影响)
- 59.6 Client Storage Creates Consistency and Security Problems(把状态放到浏览器本地会引入同步、过期、加密、篡改、跨标签页一致性和用户退出后的数据清理问题)
- 59.7 Storage Choice Should Follow Ownership and Recovery Requirements(决定使用 cookie、localStorage、sessionStorage、IndexedDB 还是 server state)
Chapter 60: Service Worker, Cache Storage, Offline Path, and Request Interception
- 60.1 Service Worker Is a Programmable Network Intermediary(Service Worker 运行在页面之外,可以拦截 fetch、管理缓存、处理离线和后台事件,使站点拥有类似客户端代理层的能力)
- 60.2 Registration, Installation, Activation, and Control Form a Lifecycle(Service Worker 要经历 install、activate、claim/control 等阶段,生命周期设计错误会让旧逻辑长期生效)
- 60.3 Fetch Event Turns Requests into Programmable Routing Decisions(Service Worker 可以在 fetch event 中决定走网络、走缓存、网络优先、缓存优先、stale-while-revalidate 或自定义 fallback)
- 60.4 Cache Storage Is Explicit Resource Ownership(不同于普通 HTTP cache,Cache Storage 由应用显式写入、读取、删除和版本化,适合 app shell、离线资源、预缓存和运行时缓存策略)
- 60.5 Offline Support Requires Data and UI Recovery Design(离线能力需要同时考虑静态文件缓存、数据读取、pending mutation、冲突解决、离线提示、恢复同步和用户信任)
- 60.6 Service Worker Update Is a Deployment Boundary(Service Worker 自身也会被缓存和更新,可能让旧资源、旧逻辑和新页面并行生效)
- 60.7 Request Interception Must Be Observable and Testable(一旦 Service Worker 介入,Network panel、cache 命中、线上回滚和用户故障定位会更复杂,因此需要明确日志、调试、版本和禁用策略)
Chapter 61: Web Worker, Shared Worker, Worklet, and Off-Main-Thread Execution
- 61.1 Workers Move JavaScript Work Outside the Main Thread(Web Worker 让计算、解析、压缩、搜索、数据处理等任务离开主线程,DOM 操作仍回到主线程协调)
- 61.2 Message Passing Defines the Worker Boundary(主线程和 Worker 之间通过 postMessage、structured clone、transferable、SharedArrayBuffer 等机制通信)
- 61.3 Shared Worker Creates a Multi-Page Coordination Point(Shared Worker 可以被同源多个页面共享,适合跨 tab 连接复用、状态协调和后台计算,但生命周期和兼容性需要谨慎评估)
- 61.4 Worklets Serve Specialized Low-Latency Pipelines(AudioWorklet、PaintWorklet、AnimationWorklet 等 worklet 是服务特定渲染、音频或动画管线的轻量执行环境)
- 61.5 Off-Main-Thread Architecture Requires Ownership Design(Worker 架构需要设计数据在哪里拥有、何时复制、何时转移、如何取消、如何回传结果和如何处理错误)
- 61.6 Worker Failure and Lifecycle Must Be Part of the System Model(Worker 可能崩溃、被终止、加载失败或与主线程状态脱节;大型应用需要重启策略、错误传播、版本同步和调试工具)
Chapter 62: WebSocket, Server-Sent Events, WebRTC, and WebTransport
- 62.1 Realtime Web Breaks the Simple Request/Response Assumption(WebSocket、SSE、WebRTC、WebTransport 让 Web 应用拥有长连接、服务端推送、双向通信、低延迟数据通道和实时媒体路径,超出了普通 fetch 请求模型)
- 62.2 WebSocket Provides Bidirectional Application Messages(WebSocket 在浏览器和服务器之间建立持久双向消息通道,适合聊天、协作、通知、行情和游戏状态,但需要处理心跳、重连、顺序和背压)
- 62.3 Server-Sent Events Provide Server-to-Client Stream Semantics(SSE 更偏服务器向浏览器持续推送文本事件,适合通知、进度、日志和流式输出;它比 WebSocket 简单,但需要区分双向通道)
- 62.4 WebRTC Creates Peer Media and Data Paths with Signaling Outside the API(WebRTC 支持浏览器之间的音视频和数据通信,但连接建立依赖应用自定义 signaling;这让实时媒体系统同时涉及浏览器 API、网络穿透、codec、加密和服务端协调)
- 62.5 WebTransport Targets Low-Latency Client-Server Transport(WebTransport 面向低延迟、双向、多流或不可靠数据传输场景,适合比普通 HTTP 更实时、比 WebRTC 更偏 client-server 的通信路径)
- 62.6 Realtime State Requires Ordering, Recovery, and Backpressure Design(实时系统必须处理消息乱序、断线重连、重复事件、状态快照、增量补丁、服务端广播、客户端回放和流量控制)
- 62.7 Realtime Communication Is a State Synchronization Problem(选择 WebSocket、SSE、WebRTC 或 WebTransport 的关键是要同步什么状态、延迟要求多高、是否需要媒体、是否能容忍丢包、由谁负责恢复)
Chapter 63: File, Clipboard, Notification, Permission, and Device-Facing APIs
- 63.1 Device-Facing APIs Cross the Boundary Between Web Page and User Environment(文件、剪贴板、通知、位置、摄像头、麦克风、蓝牙、USB、传感器等 API 让网页访问用户设备能力,因此必须受到权限、安全上下文和用户意图约束)
- 63.2 File APIs Separate User-Selected Data from Arbitrary File System Access(浏览器通常只允许页面访问用户显式选择或授权的文件,文件读取、上传、拖拽、目录访问和持久句柄都需要清楚的信任边界)
- 63.3 Clipboard APIs Require User Intent and Security Constraints(剪贴板读写影响用户隐私和系统状态,需要安全上下文、用户手势或权限控制)
- 63.4 Notification and Push APIs Extend Web Apps Beyond the Open Page(通知、push、background event 可以让 Web 应用在页面不可见时仍与用户交互,但也带来打扰、权限滥用、订阅生命周期和后台执行限制)
- 63.5 Permission Prompts Are UX, Security, and Trust Boundaries(权限弹窗需要区分单纯 API 开关,它会影响用户信任、产品流程、功能降级和浏览器安全策略;过早或过度请求权限会降低授权成功率)
- 63.6 Device APIs Must Always Have Fallback and Revocation Paths(用户拒绝权限、设备不可用、权限被撤销、页面进入后台或浏览器策略变化时,应用必须有可分析的 fallback、重新请求和错误恢复路径)
- 63.7 Powerful Web APIs Turn Browser Apps into Capability-Based Systems(现代 Web 已能访问大量设备和系统能力,但这些能力越强,越需要明确授权边界、数据最小化、可观察性和用户控制)
Part 10: Browser-Enforced Security, Permission, Isolation, and Trust Boundaries
Chapter 64: Same-Origin Policy and Cross-Origin Constraints
- 64.1 Origin Is the Browser’s Basic Security Boundary(origin 通常由 scheme、host、port 共同决定,是浏览器判断两个资源是否属于同一安全边界的基础)
- 64.2 Same-Origin Policy Restricts Script-Level Access(same-origin policy 主要限制一个页面中的脚本读取或操作另一个 origin 的敏感数据、DOM、storage 和响应内容)
- 64.3 Cross-Origin Embedding Is Different from Cross-Origin Reading(Web 允许跨源加载图片、脚本、样式、iframe、媒体等资源,同时把脚本读取响应内容作为更高权限能力)
- 64.4 Cookies and Requests Complicate Origin Boundaries(浏览器可能会随请求发送 cookie,使跨站请求携带用户身份;CSRF 防护需要在请求意图、凭证发送和服务端校验上共同设计)
- 64.5 Origin Boundaries Interact with DOM, Storage, Fetch, and Frame Access(origin 会影响 DOM access、storage isolation、Fetch response visibility、iframe relationship 和 postMessage trust)
- 64.6 Cross-Origin Constraints Are Product Architecture Constraints(多域名、多子域、CDN、API 域、静态资源域、第三方登录、嵌入式页面和多租户系统,都必须在 origin 边界下设计)
Chapter 65: CORS, Fetch Credentials, Preflight, and Resource Sharing
- 65.1 CORS Is Controlled Relaxation of Same-Origin Restrictions(CORS 是由服务器通过响应头明确允许特定跨源读取,使浏览器在受控条件下把响应暴露给调用方脚本)
- 65.2 Simple Requests and Preflight Requests Have Different Paths(某些跨源请求可以直接发送,而带有非简单 method、header 或 content type 的请求通常需要先发送 OPTIONS preflight,由服务器确认是否允许)
- 65.3 Credentials Change the Trust Model(请求携带 cookie、Authorization 或 TLS client certificate 等 credential 时,信任模型和缓存边界都会变化)
- 65.4 CORS Errors Are Browser Policy Failures(后端可能已经返回了响应,但浏览器因缺失或错误的 CORS header 拒绝把响应交给 JavaScript;这类错误需要从浏览器策略角度诊断)
- 65.5 CORS Must Be Designed with API Domains and Deployment Environments(CORS policy 要覆盖 dev/preview/prod 域名、credential、allowed method/header、CDN/proxy header 和错误诊断路径)
- 65.6 Overly Broad CORS Policies Become Data Exposure Risks(随意使用通配 origin、错误允许 credential、反射请求 origin 或缺少 method/header 限制,会把跨源访问从必要能力变成数据泄露风险)
Chapter 66: CSP, Trusted Types, Script Execution, and Injection Defense
- 66.1 CSP Defines Which Content the Browser May Load or Execute(Content Security Policy 通过 HTTP header 或 meta 配置限制脚本、样式、图片、字体、frame、worker、connect 等资源来源)
- 66.2 Script Policy Is the Most Critical CSP Boundary(script-src、nonce、hash、strict-dynamic、unsafe-inline、unsafe-eval 等策略决定哪些脚本能执行)
- 66.3 CSP Is a Browser-Enforced Contract(CSP 与输入验证、输出转义和模板安全共同组成防线,并在浏览器执行层限制恶意内容可执行能力)
- 66.4 Trusted Types Turns DOM Injection Sinks into Policy-Controlled Boundaries(Trusted Types 通过限制 innerHTML、script URL、HTML parser sink 等危险注入点,把字符串到可执行 DOM 的转换变成可审计策略)
- 66.5 CSP Must Account for Build Tools, Bundles, Inline Scripts, and Third-Party Code(现代框架和构建工具可能生成 inline script、hydration data、style injection、dynamic import、analytics script)
- 66.6 CSP Failures Need Reporting and Rollout Strategy(CSP 容易因为漏掉资源来源或错误 nonce/hash 导致线上功能失效,因此需要 report-only、violation report、灰度和监控来逐步收紧)
Chapter 67: Secure Context, HTTPS, Mixed Content, and Powerful Features
- 67.1 Secure Context Is the Gate for Powerful Web Capabilities(许多强能力 API 只在 HTTPS 或安全上下文中可用,例如 Service Worker、Clipboard、Geolocation、WebRTC、WebGPU 等)
- 67.2 HTTPS Provides Transport Security and Origin Trust(HTTPS 加密数据、建立服务器身份、保护请求和响应免遭篡改,并影响 cookie、permission、service worker 和浏览器安全默认值)
- 67.3 Mixed Content Breaks the Security Assumption(HTTPS 页面加载 HTTP 脚本、图片、iframe 或媒体时,会破坏安全上下文的一致性;浏览器会阻止或降级不同类型的 mixed content)
- 67.4 Upgrade and Redirect Strategies Affect Security and Availability(HTTP 到 HTTPS 的重定向、HSTS、证书更新、CDN TLS 配置和子资源升级策略,会共同影响站点安全和可用性)
- 67.5 Local Development and Preview Environments Need Security Parity(很多只在 secure context 下工作的能力,在本地、预览部署和测试环境也要考虑 HTTPS 或等价安全环境,否则开发结果与生产行为不一致)
- 67.6 Secure Context Is an Architecture Baseline(现代 Web 应用如果需要 Service Worker、权限 API、媒体、设备、GPU 或更强安全策略,就必须把 secure context 当成基础架构要求)
Chapter 68: Cookie Security, Storage Partitioning, and Tracking Prevention
- 68.1 Cookie Attributes Shape Browser-Side Trust(Secure、HttpOnly、SameSite、Domain、Path、Expires/Max-Age、Partitioned 共同决定 cookie 的发送、读取和生命周期)
- 68.2 SameSite Changes Cross-Site Request Behavior(SameSite 通过限制 cookie 在跨站请求中的发送行为,降低 CSRF 风险,但也会影响第三方登录、嵌入式应用、支付回跳和跨域产品集成)
- 68.3 HttpOnly Protects Against Script-Level Token Theft(HttpOnly cookie 隔离 JavaScript 读取路径,降低 XSS 后直接窃取 session token 的风险;同站请求仍需要 CSRF 与行为校验)
- 68.4 Storage Partitioning Limits Cross-Site Tracking and Shared State(现代浏览器会对 cookie、cache、storage、network state 等进行分区或限制,减少第三方上下文追踪用户的能力,也改变嵌入式应用和跨站集成的假设)
- 68.5 Tracking Prevention Makes Browser Behavior Product-Dependent(Safari、Firefox、Chrome 等浏览器的隐私策略不同)
- 68.6 Cookie and Storage Strategy Must Match Auth, Embed, and Privacy Needs(登录态、跨子域、第三方嵌入、analytics、A/B testing、CDN 缓存和隐私合规都需要统一设计 cookie 与 storage 策略)
Chapter 69: iframe Sandbox, COOP, COEP, CORP, and Cross-Origin Isolation
- 69.1 iframe Creates an Embedded Browsing Context Boundary(iframe 把一个页面嵌入另一个页面中,形成独立的 browsing context,同时引入导航、权限、尺寸、消息通信、加载和安全边界)
- 69.2 Sandbox Restricts Embedded Content Capabilities(iframe sandbox 可以限制脚本、表单、弹窗、导航、同源访问、下载等能力,用于降低嵌入不可信内容的风险)
- 69.3 COOP Controls Opener Relationships Across Windows(Cross-Origin-Opener-Policy 限制跨源窗口之间的 opener 关系,减少被其他页面持有引用和进行跨站泄漏的风险)
- 69.4 COEP Controls Which Cross-Origin Resources Can Enter the Page(Cross-Origin-Embedder-Policy 要求嵌入的跨源资源显式允许被加载,使页面能够建立更强的跨源隔离前提)
- 69.5 CORP Lets Resources Declare Who May Embed Them(Cross-Origin-Resource-Policy 让资源声明是否允许跨源嵌入或读取,从资源提供方角度控制跨站使用边界)
- 69.6 Cross-Origin Isolation Enables Powerful but Sensitive Features(SharedArrayBuffer、高精度计时、部分高性能能力依赖更强隔离;这些能力要求页面、子资源、worker 和第三方资源共同满足隔离条件)
- 69.7 Embedding Architecture Must Treat Isolation as a System Contract(广告、支付、第三方 widget、文档预览、低代码 iframe、跨域 dashboard 等嵌入场景,都必须明确谁能嵌入谁、谁能通信、谁能读取状态)
Chapter 70: Permission Prompt, User Consent, and Capability Access Boundary
- 70.1 Permissions Are User-Mediated Capability Grants(位置、相机、麦克风、通知、剪贴板、蓝牙、USB、文件系统、传感器等能力通常需要浏览器基于用户意图授予权限)
- 70.2 Permission Prompts Are Part of Product Flow(权限请求出现的时机、上下文和解释会影响授权率与用户信任;过早、过频或缺少说明的权限弹窗会被用户拒绝)
- 70.3 Permission State Can Change Over Time(权限可能被允许、拒绝、临时授权、撤销或受浏览器策略限制;应用需要持续读取当前授权状态)
- 70.4 Powerful APIs Require Secure Context and User Activation(许多敏感 API 会同时要求 HTTPS、用户手势、可见页面、焦点状态或特定权限状态,以约束后台滥用)
- 70.5 Permission Failure Must Have a Recovery Path(用户拒绝权限、设备不存在、浏览器不支持、系统设置禁用或权限过期时,应用需要提供替代路径、重新请求说明和可分析错误反馈)
- 70.6 Capability Access Should Follow Data Minimization(请求权限时应只访问完成任务所需的最小能力和最少数据,把用户设备能力纳入显式授权资源)
Chapter 71: Extension, WebView, Embedded Browser, and Trust Boundary Risk
- 71.1 Browser Extensions Run with Different Privilege Assumptions(扩展可能拥有普通网页没有的权限,例如访问页面内容、修改请求、读取浏览历史或调用浏览器扩展 API,因此它们会改变页面安全假设)
- 71.2 Content Scripts Create a Boundary Between Extension and Page(content script 在扩展和网页之间形成特殊桥接层,既能观察或修改页面,又受到 isolated world、message passing 和权限声明约束)
- 71.3 WebView Embeds the Web into a Native Trust Model(WebView 把 Web 页面放进移动端、桌面端或混合应用的 native 容器中,安全边界同时包括浏览器、宿主应用、桥接 API 和平台权限)
- 71.4 Native Bridges Are High-Risk Capability Boundaries(WebView bridge、extension message、native API wrapper 会把页面输入连接到文件、设备、账号、支付或系统权限)
- 71.5 Embedded Browsers Often Differ from Full Browsers(嵌入式 WebView 可能缺少完整地址栏、安全提示、扩展隔离、自动更新、调试能力或现代 API 支持,需要单独评估能力边界)
- 71.6 Third-Party Extensions and Embedded Contexts Must Be Treated as Environmental Risk(企业插件、广告扩展、密码管理器、内嵌 SDK、低代码容器、超级 App WebView 都可能改变 DOM、网络、storage 和权限路径)
- 71.7 Trust Boundary Analysis Must Include the User’s Browser Environment(完整 Web 安全分析需要同时考虑应用代码、服务器、浏览器配置、扩展、WebView 宿主、企业策略、隐私设置和设备环境)
Part 11: High-Performance Web Capabilities Across GPU, Media, Worker, and Realtime Paths
Chapter 72: Canvas and SVG Drawing Paths in the Document Runtime
- 72.1 Canvas and SVG Represent Two Different Drawing Models(Canvas 更偏立即模式绘制,开发者通过脚本直接操作像素或绘图上下文;SVG 更偏保留模式图形,图形节点存在于文档结构中,可被样式、事件和可访问性系统观察)
- 72.2 Canvas Turns Drawing into Script-Controlled Raster Work(Canvas 适合动态图形、图表、游戏、图像处理和自定义渲染,但它把许多语义、命中测试、可访问性和结构信息交给应用自己维护)
- 72.3 SVG Integrates Graphics into the Document Model(SVG 元素可以参与 DOM、CSS、event、layout 和 accessibility 体系,更适合图标、矢量图、交互图表和结构化图形)
- 72.4 Canvas and SVG Have Different Performance Failure Modes(Canvas 的问题常来自过度重绘、像素处理、主线程压力和分辨率缩放;SVG 的问题常来自节点过多、复杂滤镜、路径计算和 DOM 更新成本)
- 72.5 Drawing Model Choice Affects Accessibility and Interaction(选择 Canvas 或 SVG 会影响性能,也影响元素能否被搜索、能否被辅助技术分析、能否独立响应事件以及能否被 CSS 控制)
- 72.6 High-Performance Drawing Requires Coordinating Main Thread, Worker, and GPU Paths(复杂绘制需要协调 main thread 更新、OffscreenCanvas/worker、GPU resource、frame budget 和 accessibility fallback)
Chapter 73: WebGL Rendering Path Through Browser and GPU
- 73.1 WebGL Exposes a GPU Rendering Pipeline Through the Browser(WebGL 让网页可以通过浏览器访问 GPU 渲染能力,但它仍然受到浏览器安全、资源限制、上下文管理和图形驱动兼容性的约束)
- 73.2 WebGL Context Is a Capability Boundary(获取 WebGL context 是浏览器授予页面访问图形管线的能力,可能受到硬件、浏览器策略、驱动黑名单和安全限制影响)
- 73.3 Buffers, Textures, Shaders, and Draw Calls Form the Rendering Path(WebGL 应用需要管理顶点数据、索引、纹理、shader program、uniform、framebuffer 和 draw call,这些资源最终转化为 GPU 执行命令)
- 73.4 Browser Mediation Changes Native Graphics Assumptions(WebGL 需要区分原生 OpenGL 的直接暴露,浏览器需要验证参数、限制危险行为、处理上下文丢失、防止越界访问,并与 compositor pipeline 协作)
- 73.5 Context Loss Is a First-Class Failure Mode(WebGL context 可能因为 GPU reset、资源压力、驱动问题或浏览器策略丢失;应用必须能释放、重建和恢复图形资源)
- 73.6 WebGL Performance Is Bound by CPU-GPU Coordination(性能瓶颈可能来自 shader、JavaScript 调度、状态切换、资源上传、draw call 数量、纹理带宽、同步读取和主线程压力)
- 73.7 WebGL Fits the Web When Resource Lifetime Is Explicit(WebGL 项目需要显式管理 context、buffer、texture、shader、framebuffer、dispose、context loss 和降级路径)
Chapter 74: WebGPU as a Web Platform Capability Boundary
- 74.1 WebGPU as a Broader System(WebGPU 是更接近现代 GPU API 的 Web 平台能力,面向显式资源管理、命令提交、compute pipeline 和更可预测的 GPU 工作模型)
- 74.2 Adapter and Device Requests Define Hardware Capability Discovery(WebGPU 通过 adapter 和 device 把硬件能力、限制、feature、format、性能等级和浏览器策略暴露为受控能力发现过程)
- 74.3 Browser Sandbox Mediates GPU Access(页面访问 GPU 必须经过浏览器验证、隔离、资源限制和安全检查,使 GPU 路径保持系统稳定性和数据边界)
- 74.4 WebGPU Moves More Responsibility to the Application(WebGPU 让应用负责 device、buffer/texture、pipeline、bind group、command encoder、queue submit 和错误范围)
- 74.5 Compute Capability Changes What Web Apps Can Do(WebGPU 的 compute pipeline 让图像处理、物理模拟、数据并行计算、机器学习前处理、粒子系统和可视化计算更适合在浏览器中执行)
- 74.6 WebGPU Must Be Designed with Fallback and Capability Detection(不同浏览器、设备、GPU、驱动和安全上下文可能支持差异明显,因此 WebGPU 应用必须考虑 feature detection、fallback、降级渲染和错误恢复)
- 74.7 WebGPU Belongs to Web System Architecture(在 Web 书中讲 WebGPU,重点是解释它如何改变浏览器能力边界、性能路径、worker 协作、资源生命周期和应用形态)
Chapter 75: WebGPU Resource, Queue, Shader, and Security Execution Path
- 75.1 Resource Creation Defines GPU Memory Ownership(buffer、texture、sampler、bind group 等资源创建后进入 GPU 资源生命周期,应用需要明确谁创建、谁更新、何时释放、何时可复用)
- 75.2 WGSL and Shader Modules Define Executable GPU Programs(WGSL shader module 把可执行 GPU 逻辑带入浏览器,并经过验证、类型检查和安全限制后进入 GPU pipeline)
- 75.3 Pipeline Objects Encode Execution Configuration(render pipeline 和 compute pipeline 把 shader、layout、format、状态和资源绑定规则固定为 GPU 可执行配置)
- 75.4 Command Encoding Separates Recording from Submission(command encoder 先记录 GPU 工作,再通过 queue submit 提交执行;这让应用能够批量组织 GPU 命令,但也要求分析 CPU/GPU 异步关系)
- 75.5 Queue Submission Is an Asynchronous Boundary(提交命令并需要结合上下文判断 GPU 立即完成,读回结果、帧呈现、资源复用和错误处理都必须考虑异步执行和同步点成本)
- 75.6 Validation and Error Scopes Make GPU Failure Observable(WebGPU 通过 validation、error scope、device lost 等机制把一部分 GPU 错误暴露给应用)
- 75.7 Security Constraints Shape the WebGPU Programming Model(为了防止信息泄漏、越界访问、未初始化数据读取和驱动崩溃,WebGPU 的设计必须在性能和浏览器安全之间做平衡)
Chapter 76: WebCodecs and Media Source as Browser Media Pipeline
- 76.1 Browser Media Is a Pipeline(媒体播放连接 network、container、demux、decode、buffer、clock、rendering、audio output 和 user control)
- 76.2 Media Source Extensions Let JavaScript Feed Media Buffers(Media Source Extensions 允许应用通过 JavaScript 把媒体片段送入浏览器媒体缓冲区)
- 76.3 WebCodecs Exposes Lower-Level Encode and Decode Control(WebCodecs 让应用更直接地访问编码/解码能力,适合视频编辑、实时处理、低延迟媒体、远程桌面、云游戏和自定义媒体管线)
- 76.4 Media Pipeline Requires Timing and Backpressure Management(媒体数据需要区分普通字节流,必须处理帧时间戳、解码队列、丢帧、缓冲区、音画同步、播放速率和内存压力)
- 76.5 Hardware Acceleration Is Powerful but Device-Dependent(浏览器可能利用硬件解码和编码,但 codec、profile、分辨率、色彩格式、功耗和系统权限会因设备与浏览器而异)
- 76.6 Media Errors Cross Network, Codec, DRM, and Rendering Boundaries(视频播放失败可能来自网络、manifest、CORS、codec 不支持、解码失败、MSE append 错误、DRM、autoplay 策略或渲染输出问题)
- 76.7 Advanced Web Media Architecture Needs Explicit Pipeline Ownership(复杂媒体应用必须明确谁负责下载、缓存、解码、同步、渲染、错误恢复和降级,并明确
<video>默认行为覆盖不到的责任)
Chapter 77: Web Audio Graph, Timing, and Real-Time Scheduling
- 77.1 Web Audio Represents Sound as a Processing Graph(Web Audio API 通过 AudioContext 和 AudioNode 构成音频处理图,把音源、增益、滤波、分析、空间化和输出连接成可编程音频管线)
- 77.2 Audio Timing Has Stricter Requirements Than Ordinary UI Updates(音频对时间抖动非常敏感,普通主线程 UI 卡顿、timer 延迟或 GC 停顿都可能造成爆音、延迟和同步错误)
- 77.3 AudioContext Owns Time, State, and Output Destination(AudioContext 维护音频时间线、节点连接、调度事件和输出目标,是 Web 音频系统的运行时中心)
- 77.4 AudioWorklet Moves Custom Processing into a Real-Time Path(AudioWorklet 允许自定义音频处理进入更接近实时音频线程的路径,但要求低延迟、少分配、可预测执行和清晰消息通信)
- 77.5 Media, WebRTC, and Web Audio Can Share Streams(麦克风输入、媒体元素、WebRTC track、AudioBuffer、MediaStream 和 Web Audio graph 可以组合,形成录音、处理、传输、可视化和播放系统)
- 77.6 Browser Policies Affect Audio Start and Playback(自动播放策略、用户手势、页面可见性、后台节流、设备切换和权限变化都会影响音频启动、暂停和恢复)
- 77.7 Web Audio Architecture Must Treat Latency as a First-Class Constraint(音乐工具、语音通信、游戏、实时互动和音频可视化都需要把延迟、同步、缓冲、线程边界和恢复路径作为核心设计对象)
Chapter 78: Capture, WebRTC Media Path, and Privacy Boundary
- 78.1 Media Capture Starts with User Permission and Device Selection(摄像头、麦克风、屏幕共享都需要用户授权和设备选择,浏览器必须明确告诉用户哪些能力正在被网页使用)
- 78.2 MediaStream and Tracks Represent Live Capability Handles(MediaStream 和 track 是指向实时设备、屏幕、远端媒体或处理管线的能力句柄,需要处理启停、mute、ended、replace 和权限撤销)
- 78.3 WebRTC Splits Signaling from Media Transport(WebRTC API 负责 peer connection、track、data channel、ICE、DTLS、SRTP 等通信能力)
- 78.4 ICE, NAT Traversal, and Relay Servers Become Architecture Concerns(真实网络下浏览器之间可能能直接连接,STUN、TURN、ICE candidate、relay 成本和网络策略都会影响 WebRTC 系统可靠性)
- 78.5 Screen Capture Has Stronger Privacy and UX Constraints(屏幕共享可能暴露窗口、标签页、系统通知、其他应用和敏感信息,因此浏览器需要更严格的选择 UI、可见提示和停止共享机制)
- 78.6 Realtime Media Requires Recovery from Network and Device Changes(网络切换、设备拔出、权限撤销、带宽下降、编码器变化、丢包、延迟上升都需要动态降级和恢复路径)
- 78.7 Privacy Boundary Is Part of Media Architecture(实时音视频系统需要同时设计 codec、延迟、权限请求、用户提示、设备状态、最小采集、远端泄漏和数据保留边界)
Chapter 79: Worker, WASM, GPU, and Media Coordination for High-Performance Web Apps
- 79.1 High-Performance Web Apps Are Multi-Pipeline Systems(复杂 Web 应用可能同时使用 Worker、WASM、WebGPU、WebCodecs、Web Audio、WebRTC、Canvas 和 DOM,它们是多个执行管线协作)
- 79.2 Worker Separates Computation from UI Responsiveness(把计算、解码、解析、仿真、压缩或数据处理放入 Worker,可以保护主线程交互,但需要管理消息传递、数据复制、transferable 和错误传播)
- 79.3 WASM Brings Native-Like Compute into the Web Sandbox(WASM 可以把 C/C++/Rust 等编译产物放入浏览器沙箱执行,适合性能敏感任务,但仍受内存模型、JS binding、线程能力和浏览器安全限制)
- 79.4 GPU and Media Pipelines Are Asynchronous to JavaScript(WebGPU、WebGL、WebCodecs、Web Audio 和 WebRTC 的工作往往在 JavaScript 调用之后异步继续)
- 79.5 Data Movement Often Dominates Performance(structured clone、transferable、SharedArrayBuffer、copy、serialization 和 GPU upload 常常比计算本身更影响速度)
- 79.6 Pipeline Coordination Needs Backpressure and Scheduling Strategy(视频帧、音频块、GPU 命令、网络消息、用户输入和 UI 更新都需要调度;缺少 backpressure 会导致延迟增长、内存膨胀和掉帧)
- 79.7 High-Performance Web Architecture Is Capability Orchestration(的高性能 Web 架构是清楚划分每条管线的职责、数据所有权、同步边界、失败恢复和用户可见结果)
Part 12: UI Runtime, Component Model, State, and Interaction Feedback
Chapter 80: UI Runtime as the Bridge Between State and DOM
- 80.1 UI Runtime Sits Between Application State and Browser DOM(UI runtime 的核心职责是在应用状态变化和真实 DOM 更新之间建立可维护、可调度、可组合的转换层)
- 80.2 Declarative UI Describes Desired Output(声明式 UI 让开发者描述某个状态下界面应该是什么样子,减少手写 DOM 创建、插入、删除和更新命令的负担)
- 80.3 Rendering Is a State-to-Tree Transformation(UI runtime 会把 state、props、signals、template、component boundary 转换成 DOM mutation 或 framework-specific instruction)
- 80.4 UI Runtime Must Decide What Actually Changes(状态变化会被 runtime 收敛成具体组件、节点、属性、事件、文本、样式或 effect 更新)
- 80.5 DOM Update Is Where Framework Abstraction Meets Browser Cost(框架内部的 diff、compiler output、fine-grained update 或 signal propagation 最终都会变成真实 DOM mutation)
- 80.6 UI Runtime Must Coordinate with Event Loop and Rendering Pipeline(UI runtime 的 flush、effect、layout read/write、animation frame 和 hydration 都要贴合浏览器调度)
- 80.7 The UI Runtime Is Only One Layer of the Web System(UI runtime 负责界面更新和交互协调,但不天然解决网络、身份、缓存、数据库、构建、部署和浏览器安全边界问题)
Chapter 81: Component Model, Composition, Props, and Local Responsibility
- 81.1 Component Is a Unit of UI Responsibility(组件是把 UI 结构、输入、局部状态、事件响应、生命周期和可复用边界组合成一个责任单元)
- 81.2 Props Express Parent-to-Child Data Flow(props 让父组件把数据和配置传给子组件,形成显式输入边界;props 设计不清会导致组件耦合、重复渲染和语义模糊)
- 81.3 Composition Builds Interfaces with Local Ownership(组件组合允许复杂界面由较小责任单元构成,但组合关系也会决定状态提升、事件回传、slot / children、context 和 layout 边界)
- 81.4 Local State Should Belong to the Closest Responsible Component(局部状态应放在拥有该状态和交互反馈的组件附近;过早全局化会扩大更新范围和认知成本)
- 81.5 Component Boundary as a Structured System(组件边界用于组织 UI,同时要区分数据 ownership、缓存 ownership、server state、form state 和 URL state 的跨组件范围)
- 81.6 Reusable Components Need Explicit Behavioral Contracts(可复用组件需要明确 props、事件、受控/非受控状态、可访问性、样式覆盖、错误状态和加载状态)
- 81.7 Component Architecture Fails When Responsibility Is Ambiguous(当组件既负责展示、请求数据、提交 mutation、管理权限、控制路由、持有缓存和处理错误时,边界会混乱,后续维护和测试都会困难)
Chapter 82: Client State, Server State, URL State, Form State, and Cache State
- 82.1 UI State Has Different Owners(界面状态可能分别属于浏览器、URL、表单控件、客户端内存、服务器、数据库、缓存或第三方系统)
- 82.2 Client State Represents Local Interaction Memory(展开面板、当前 tab、临时输入、hover、modal 开关、拖拽状态等通常是 client state,主要服务当前会话和当前界面交互)
- 82.3 Server State Represents Remote Truth with Local Copies(用户资料、订单、文章、权限、评论、库存等数据的权威来源通常在服务器或数据库,客户端只是持有缓存副本,因此需要 loading、error、refresh 和 stale 管理)
- 82.4 URL State Is Shareable and Navigable State(搜索条件、分页、排序、筛选、语言、当前资源 ID 等适合放入 URL,因为它们需要可分享、可回退、可刷新和可索引)
- 82.5 Form State Is User-Editable Pending Intent(表单状态是用户正在编辑、尚未提交或等待校验的意图,必须处理 touched、dirty、valid、pending、error 和 reset)
- 82.6 Cache State Is Derived, Expirable, and Shared(query cache、framework cache、browser cache、CDN cache 都是为了性能和可用性保存的副本)
- 82.7 State Misclassification Creates Architecture Bugs(把 server state 当 client state、把 URL state 放到内存、把 form state 过早提交、把 cache 当真相)
Chapter 83: Virtual DOM, Fine-Grained Reactivity, Signals, and Compiler-Driven UI
- 83.1 UI Runtimes Differ in How They Detect and Apply Change(不同框架的核心差异之一,是如何发现状态变化、定位受影响 UI、生成更新计划并把变化应用到 DOM)
- 83.2 Virtual DOM Uses Re-Rendering and Reconciliation(Virtual DOM 模型通常通过重新执行组件渲染逻辑生成新的 UI 描述,再与旧描述比较,最终对真实 DOM 做必要更新)
- 83.3 Fine-Grained Reactivity Tracks Dependencies More Precisely(fine-grained reactivity 通过追踪具体响应式依赖)
- 83.4 Signals Make Reactive Values Explicit(signal 把可变响应式值包装成可被追踪的单元,使 runtime 能建立依赖图、传播更新并减少不必要的组件级重新执行)
- 83.5 Compiler-Driven UI Moves Work from Runtime to Build Time(Svelte、Vue compiler、Solid compiler、template compiler 等方式会在构建阶段分析模板或组件结构)
- 83.6 No Update Model Eliminates Browser Cost(无论使用 Virtual DOM、signals、compiler output 还是手写 DOM)
- 83.7 Choosing a UI Runtime Is Choosing a Change Propagation Model(比较 UI 框架需要检查它如何传播状态变化、如何调度更新、如何处理副作用、如何与浏览器渲染路径协作)
Chapter 84: Scheduling, Priority, Batching, and User-Perceived Responsiveness
- 84.1 UI Update Timing Is Part of User Experience(状态变化何时变成屏幕变化,会影响用户是否感觉界面及时响应;正确但延迟的 UI 仍然可能是糟糕体验)
- 84.2 Batching Reduces Redundant Work but Changes Timing(批处理可以把多次状态变化合并为一次更新,减少重复 render 和 DOM mutation,但也会改变读取状态、执行 effect 和用户看到反馈的时机)
- 84.3 Priority Separates Urgent Feedback from Deferred Work(输入反馈、点击响应、焦点变化等通常比后台列表过滤、图表重算、非关键动画更紧急;UI runtime 需要区分不同更新优先级)
- 84.4 Scheduling Must Respect the Browser Main Thread(调度策略需要考虑 long task、input priority、microtask queue、render opportunity、idle time 和 GC pause)
- 84.5 Concurrent and Interruptible Rendering Changes Mental Models(可中断、可恢复或分片的渲染模型可以改善响应性,副作用需要放入 commit/effect 等稳定阶段)
- 84.6 Expensive UI Work Should Be Split, Deferred, or Moved(大列表、复杂图表、搜索过滤、富文本编辑、拖拽排序和动画计算等工作需要通过虚拟列表、memoization、worker、idle task 或增量更新控制成本)
- 84.7 Responsiveness Is Measured by the User(框架调度能力需要通过 input delay、INP、long task、frame drop 和真实用户体验验证)
Chapter 85: Event Handling, Feedback Loop, and Interaction Recovery
- 85.1 UI Interaction Starts with Browser Events(点击、输入、键盘、滚动、指针、拖拽、提交、焦点变化等事件首先来自浏览器事件系统,然后才进入框架封装和应用逻辑)
- 85.2 Event Handling Converts User Intent into State Transition(事件处理器的核心任务是解释用户意图,并把它转换成状态变化、请求、导航、表单提交、弹窗打开或其他系统行为)
- 85.3 Immediate Feedback Protects User Trust(用户操作后需要看到 pressed、loading、disabled、pending、error、success、undo 等反馈,否则即使后台逻辑正确,也会感觉界面无响应或不可靠)
- 85.4 Default Browser Behavior and Framework Behavior Must Coordinate(表单提交、链接导航、焦点移动、键盘快捷键、滚动、拖拽、文本选择等默认行为如果被框架错误拦截,会破坏可访问性和用户预期)
- 85.5 Interaction Recovery Handles Failure After User Intent(请求失败、权限拒绝、网络断开、重复点击、乐观更新失败、路由切换中断时,UI 必须能恢复、回滚、重试或解释状态)
- 85.6 Event Propagation Defines Local and Global Responsibility(capture、target、bubble、delegation、stopPropagation、shadow boundary 决定交互责任落在哪一层)
- 85.7 Feedback Loop Is a Full-Stack Path(用户点击后的视觉反馈可能穿过 event handler、state update、mutation、network、cache invalidation 和重新渲染)
Chapter 86: Startup Interactivity, Client JavaScript Budget, and UI Activation Cost
- 86.1 Startup Interactivity Begins Before the First Click(用户能否快速交互取决于页面显示、JavaScript 下载解析执行、事件处理器绑定和状态恢复)
- 86.2 Client JavaScript Budget Is an Architecture Constraint(client bundle 的下载、解析、编译、执行、hydration、memory 和 long task 都属于架构预算)
- 86.3 UI Activation Requires Code, Data, and Event Readiness(按钮、表单、菜单、路由和交互组件可用,需要相关代码已加载、状态已准备、事件处理器可执行、错误路径可处理)
- 86.4 Too Much Client Runtime Turns Fast HTML into Slow Interaction(SSR 或 SSG 可以快速显示 HTML,但如果后续需要大量客户端 JavaScript 激活,用户仍可能遇到可见但不可交互的页面)
- 86.5 Code Splitting Improves Load Only If It Matches Interaction Priority(代码拆分应根据首屏、首交互、路由边界、用户意图和预取策略设计;随意拆分可能造成点击后等待 chunk、重复请求和体验抖动)
- 86.6 Third-Party Scripts Compete with Application Interactivity(广告、分析、客服、A/B testing、监控和第三方 SDK 会占用网络、主线程和事件循环,必须纳入 interactivity budget)
- 86.7 UI Activation Cost Must Be Observable(activation 需要用 bundle size、coverage、long task、interaction delay、hydration marker 和 device profile 观察)
Part 13: Routing, Navigation State, and Application Flow
Chapter 87: URL as Application State and Public Interface
- 87.1 URL Is the Most Stable State Boundary in Web Applications(URL 同时页面地址,它是用户、浏览器、服务器、CDN、搜索引擎、分享链接和应用路由共同分析的公共状态边界)
- 87.2 Path, Query, and Fragment Encode Different Kinds of State(path 通常表达资源层级或页面位置,query 适合表达搜索、过滤、分页和排序等可分享状态,fragment 更偏文档内部定位或客户端局部状态)
- 87.3 URL State Survives Refresh, Share, Bookmark, and Server Entry(放进 URL 的状态天然可以刷新恢复、分享复制、被收藏、被服务端识别,也能支持深链接和跨设备入口)
- 87.4 Memory-Only State Breaks Public Navigation Semantics(如果关键页面状态只存在于 JavaScript memory 或组件 state 中,刷新、返回、复制链接、服务端渲染和搜索发现都会变得脆弱)
- 87.5 URL Design Affects Routing, Cache, SEO, Analytics, and Permissions(URL 结构会影响路由匹配、CDN 缓存键、canonical、日志分析、权限范围、重定向策略和长期兼容性)
- 87.6 Application State Should Be Classified Before It Is Stored(决定状态放在 URL、form、client memory、server session、database 或 cache 前,必须先判断它是否需要分享、恢复、索引、保密或持久化)
Chapter 88: Route Match, Nested Route, Layout, and Segment Boundary
- 88.1 Route Matching Turns URL into Application Structure(路由匹配把 URL path、params、query 和 method 映射到应用中的页面、layout、handler、loader、action 或组件边界)
- 88.2 Route Parameters Create Typed Resource Context(动态路由参数把 URL 中的文本片段转成资源上下文,例如 user id、post slug、tenant、locale 或 product id)
- 88.3 Nested Routes Encode Shared Layout and Shared State Boundaries(嵌套路由让父级 layout、导航、权限、数据和错误边界能被子页面共享,减少重复,但也会增加状态继承和失效范围复杂度)
- 88.4 Layout Boundaries Decide What Survives Navigation(一次导航后哪些 UI 保留、哪些重新渲染、哪些数据重新加载、哪些 scroll/focus 重置,往往由 layout 和 route segment 边界决定)
- 88.5 Route Segments Become Data and Code Splitting Boundaries(route segment 会决定 layout reuse、loader scope、bundle split、prefetch unit、cache key 和 error/loading boundary)
- 88.6 Route Matching Failure Is a User-Facing State(404、权限不足、资源不存在、参数非法、locale 不支持、tenant 不存在等都是路由系统需要明确表达的用户可见状态)
Chapter 89: File-Based Routing, Route Module, and Framework Routing Contracts
- 89.1 File-Based Routing Turns Directory Structure into Public Behavior(file-based routing 把文件路径、目录层级、命名约定和特殊文件转化为 URL 行为、layout 关系、数据加载入口和构建产物边界)
- 89.2 Route Module Groups UI, Data, Metadata, and Error Handling Around a Path(route module 往往把组件、loader、action、metadata、headers、error boundary 和 handle 等逻辑组织在同一路由边界下)
- 89.3 Routing Convention Is a Framework Contract(file-based routing、nested routes、layout routes、dynamic segment 和 route group 会把目录结构变成应用边界)
- 89.4 Route Modules Can Improve Locality but Create Coupling(把 UI、数据、mutation 和错误处理放在同一路由附近能提升局部分析性,但也可能让业务逻辑与框架路由结构强耦合)
- 89.5 Generated Route Manifests Connect Build Time and Runtime(许多框架会在构建时生成 route manifest、chunk graph、loader map、server output 或 static path)
- 89.6 Framework Routing Must Still Respect Platform Navigation(框架 router 仍要处理 URL、history、scroll、focus、reload、deep link、form submit 和 browser back/forward)
Chapter 90: Client Navigation, History API, and Transition Semantics
- 90.1 Client Navigation Reuses the Current Document(客户端导航通常在当前 document 中修改 URL、加载数据、更新 UI、保存历史状态和恢复交互体验)
- 90.2 History API Bridges Browser Buttons and Application State(
pushState()、replaceState()和popstate让应用可以创建和响应 history entry) - 90.3 Navigation Transition Has Start, Pending, Commit, and Recovery Phases(一次客户端导航通常包含用户意图、路由匹配、数据加载、pending UI、提交 UI 更新、滚动/焦点恢复和失败恢复等阶段)
- 90.4 Abort and Race Handling Are Navigation Requirements(用户连续点击、快速返回、搜索条件变化、网络延迟和组件卸载会导致旧导航结果晚于新导航返回,因此导航系统必须处理取消、乱序和过期结果)
- 90.5 Client Navigation Must Preserve User Expectations(客户端路由需要保留链接复制、返回按钮、刷新恢复、加载反馈、错误恢复、滚动和焦点等浏览器级预期)
- 90.6 Navigation Semantics Are Shared by Router, Data Layer, and UI Runtime(一次 navigation 同时改变 route match、data request、pending UI、cache freshness、scroll/focus 和 error boundary)
Chapter 91: Loading Boundary, Error Boundary, Redirect, and Missing Routes
- 91.1 Loading Boundary Makes Pending Navigation Visible(loading boundary 把 pending route、deferred data、suspense fallback 和用户可见等待状态放到明确位置)
- 91.2 Error Boundary Localizes Failure Impact(error boundary 把数据错误、渲染错误、权限错误、资源不存在、网络失败等限制在合适的路由或 layout 范围内,保持应用其它区域可用)
- 91.3 Redirect Is Control Flow Across Navigation Boundaries(redirect 需要区分普通 response,它会改变当前导航路径、history 行为、数据加载顺序、缓存和用户可见 URL)
- 91.4 Missing Routes Are Routing States(404 可能来自无匹配路由、资源缺失、租户缺失、权限隐藏、locale 无效或数据被删除,应由路由和数据层共同表达)
- 91.5 Boundary Placement Defines Failure Granularity(边界越靠近局部组件,失败越局部;边界越靠近 layout 或 route,恢复和上下文保留方式越不同)
- 91.6 Good Boundaries Preserve Context During Failure(失败时尽量保留导航上下文、已加载 layout、用户输入、重试入口和可分析解释,让错误页保留用户上下文)
Chapter 92: Navigation Prefetch, Restoration, and Experience
- 92.1 Prefetch Turns Probable Navigation into Early Work(prefetch 可以提前加载未来页面需要的代码、数据或资源,让用户点击后更快进入目标状态,但也会消耗网络、缓存和服务器资源)
- 92.2 Prefetch Strategy Should Follow User Intent and Cost(prefetch 要结合 hover、viewport、priority、network condition、auth context、cache pollution 和 wasted request 成本)
- 92.3 Scroll Restoration Is Part of Navigation Correctness(用户返回列表、详情、搜索结果或长文档时,期望滚动位置合理恢复;浏览器提供
history.scrollRestoration,但 SPA 常常需要框架和应用共同处理) - 92.4 Focus Restoration Protects Keyboard and Assistive Navigation(路由变化后,焦点应该移动到有意义的位置,使键盘用户或屏幕阅读器用户进入当前页面的有效语义区域)
- 92.5 View Transition and Animation Need Feedback and Motion Boundaries(说明过渡动画如何服务空间连续性、关键反馈、滚动、错误表达、输入响应和 reduced-motion 偏好)
- 92.6 Navigation Experience Is More Than Faster Page Changes(好的导航体验包括可预测 URL、及时反馈、正确历史、合理滚动、焦点管理、错误恢复、可访问性和状态一致性)
Chapter 93: Route State, Form State, and Data State Coordination
- 93.1 Route State Identifies Where the User Is(route state 说明用户当前处于哪个路径、哪个资源、哪个 layout、哪个页面状态,是 UI、数据和交互的上下文基础)
- 93.2 Form State Represents Pending User Intent Inside a Route(表单状态通常属于当前路由或当前交互流程,它可能尚未提交、正在校验、等待服务器响应或需要在导航前保护)
- 93.3 Data State Represents Remote Truth or Cached Snapshot(路由显示的数据通常来自服务器、缓存或本地副本;它是否新鲜、是否正在刷新、是否可变会影响当前路由的可信度)
- 93.4 Navigation Can Interrupt Forms and Data Requests(用户离开当前路由时,未提交表单、pending mutation、正在加载的数据和长时间请求都需要明确处理,否则容易丢失输入或产生 stale update)
- 93.5 Route Changes Should Define Which State Resets and Which State Persists(搜索条件、滚动位置、layout state、tab、modal、query cache、form draft、selected item 是否保留,应由路由边界和产品语义共同决定)
- 93.6 Coordinating Route, Form, and Data State Prevents Ghost UI(如果路由已变但旧请求返回、表单还显示旧资源、缓存覆盖新数据或错误绑定到旧页面,就会出现 ghost UI、错位反馈和用户误操作)
- 93.7 Modern Routers Are State Coordination Systems(现代 router 协调 URL、history、loader/action、query cache、form draft、scroll/focus、transition 和 error recovery)
Part 14: Rendering Models, Hydration Architecture, Streaming, and Server-Client Boundaries
Chapter 94: CSR, SSR, SSG, ISR, and Hybrid Rendering Models
- 94.1 Rendering Model Defines Where HTML Is Produced(渲染模型首先回答 HTML 在哪里生成:浏览器、服务器、构建阶段、边缘运行时,还是多个位置共同生成)
- 94.2 CSR Moves Initial UI Construction to the Browser(Client-Side Rendering 通常让浏览器下载 JavaScript 后再生成主要 UI,适合强交互应用)
- 94.3 SSR Produces HTML at Request Time(Server-Side Rendering 在请求到达时生成 HTML,使用户更早看到内容)
- 94.4 SSG Produces HTML at Build Time(Static Site Generation 在构建阶段提前生成 HTML,适合内容稳定、可缓存、公开访问的页面,但需要处理内容更新、个性化和增量发布问题)
- 94.5 ISR and Incremental Static Strategies Blur Build-Time and Runtime(Incremental Static Regeneration 和类似策略让静态页面可以在运行期更新)
- 94.6 Hybrid Rendering Is the Default Reality of Modern Web(现代应用通常是按页面、route segment、组件、数据和用户状态选择不同渲染路径)
- 94.7 Rendering Model Choice Is a Boundary Decision(选择渲染模型是在首屏、交互、数据新鲜度、缓存、部署成本、SEO、安全和失败恢复之间做边界选择)
Chapter 95: Build-Time and Request-Time Rendering Output
- 95.1 Build-Time Output Captures a Snapshot of the World(构建时生成的 HTML、JSON、manifest、bundle 和 route metadata 都是某个时间点的快照;它们的正确性取决于内容更新频率和失效策略)
- 95.2 Request-Time Output Can Use Live Context(请求时渲染可以读取 cookie、authorization、locale、A/B test、实时数据和用户权限,因此更适合个性化、动态授权和强实时数据页面)
- 95.3 Static Output Moves Cost from Runtime to Build and Cache(静态生成减少每次请求的计算成本,但增加构建耗时、发布复杂度、缓存失效和内容更新延迟)
- 95.4 Dynamic Rendering Moves Cost into the Request Path(动态渲染能使用最新上下文,但会增加服务器计算、数据库访问、冷启动、超时、流量峰值和故障传播风险)
- 95.5 Partial Static and Partial Dynamic Boundaries Reduce Overcommitment(页面中的 header、layout、内容块、评论区、推荐区、用户菜单可以采用不同生成策略,不必把整页绑定到单一模式)
- 95.6 Build-Time Secrets and Runtime Secrets Need Separate Boundaries(说明构建变量、server runtime secret 和 client bundle 暴露变量的安全边界)
- 95.7 Output Timing Determines Cache and Deployment Strategy(页面是在 build time、request time、edge time 还是 client time 生成)
Chapter 96: Streaming HTML, Suspense Boundary, and Incremental UI Delivery
- 96.1 Streaming Turns Rendering into a Progressive Delivery Path(streaming HTML 让服务器可以先交付 shell、layout、fallback 或已准备好的内容,再继续生成后续页面片段)
- 96.2 Suspense Boundary Defines Where Waiting Becomes Visible(Suspense-like boundary 把等待数据、等待代码或等待组件的状态局部化,让页面可以先显示部分 UI,降低全页阻塞)
- 96.3 Streaming Requires Runtime and Proxy Cooperation(streaming 需要 server runtime、CDN、proxy、compression、browser 和框架都不把响应过度缓冲)
- 96.4 Incremental UI Delivery Changes Error Semantics(一旦部分 HTML 已经发送,后续错误需要通过边界化 fallback、error placeholder 和恢复路径处理)
- 96.5 Streaming Improves Perceived Speed Through Earlier Output(streaming 可能让用户更早看到内容,优化的是等待体验和关键路径呈现)
- 96.6 Streaming HTML Must Coordinate with Scripts, Styles, and Hydration(流式 HTML 片段需要和 CSS、script、module graph、hydration data、event binding 和客户端激活顺序协调)
- 96.7 Incremental Delivery Is a UX Contract(当系统选择渐进交付时,就必须让 loading、fallback、partial content、error 和 completion 状态对用户可分析,并让中间状态保持可解释)
Chapter 97: Hydration, Partial Hydration, Islands, and Client Activation
- 97.1 Hydration Converts Server-Produced UI into Interactive UI(hydration 通常指浏览器接收已有 HTML 后,下载并执行 JavaScript,把事件处理器、状态和框架运行时连接到现有 DOM 上)
- 97.2 Hydration Cost Comes After Visible Content(SSR 或 SSG 可以让内容较早可见,但 hydration 需要下载、解析、执行客户端 JavaScript,并可能产生用户看到页面却暂时无法交互的窗口)
- 97.3 Full Hydration Activates a Large Client Runtime Boundary(整页 hydration 会让大量组件、状态和事件处理器在客户端激活,适合复杂应用,但会增加 JavaScript 预算和主线程压力)
- 97.4 Partial Hydration Reduces Client Work by Activating Only What Needs Interaction(partial hydration 只激活部分交互区域,把静态内容保留为 HTML,从而减少不必要的客户端 JavaScript 和 activation 成本)
- 97.5 Islands Architecture Treats Interactivity as Localized Components(islands 模型把页面的大部分内容作为静态 HTML,只给需要交互的局部组件加载和执行 JavaScript,适合内容站、营销页、文档站和局部交互页面)
- 97.6 Hydration Mismatch Reveals Boundary Drift(服务器生成的 HTML 与客户端首次 render 结果不一致时,会出现 hydration mismatch,通常来自时间、随机数、locale、权限、数据快照或环境差异)
- 97.7 Client Activation Must Be Scheduled Around User Intent(需要区分所有交互都需要立即激活;可见性、空闲时间、用户输入、优先级、设备能力和网络条件都可以参与 hydration 或 activation 策略)
Chapter 98: React Server Components and Server-Client Component Boundary
- 98.1 Server Components Move Part of the UI Tree to the Server(Server Components 让部分组件只在服务器环境运行,并减少发送到浏览器的组件 JavaScript)
- 98.2 Server Components Define Server and Client Execution Placement(说明 SSR 与 Server Components 如何分别处理 HTML 预渲染和组件执行边界)
- 98.3 Client Components Mark the Interactive Browser Boundary(需要 state、effect、event handler、browser API 的组件必须位于客户端边界内,因为这些能力依赖浏览器运行时和用户交互)
- 98.4 Serialization Defines What Can Cross the Boundary(从 Server Component 到 Client Component 的数据需要可序列化,函数、数据库连接、文件句柄、secret 和特殊运行时对象留在服务端边界内)
- 98.5 Data Access Moves Closer to the Server Component Tree(Server Components 可以在服务器侧读取数据、访问后端资源或组合 server-only 逻辑,但这也要求清楚处理缓存、权限、错误和并发请求)
- 98.6 Boundary Placement Shapes Bundle Size and Mental Model(把组件放在 server 还是 client,会影响 client bundle、数据路径、交互能力、代码组织、测试方式和开发者对状态的分析)
- 98.7 RSC Architecture Must Be Read as a Boundary System(分析 RSC 需要检查哪些代码运行在 server,哪些运行在 browser,哪些数据可以跨越边界,以及失败时如何恢复)
Chapter 99: Resumability and Alternative Interactivity Models
- 99.1 Resumability Avoids Reconstructing Some Client Runtime State(resumability 模型试图让客户端从服务端输出中恢复可交互状态,减少重新执行大量组件逻辑的成本)
- 99.2 Serialization of Execution Context Is the Hard Problem(要让页面“恢复”并完成“重新激活”,系统必须记录或推导事件处理器、组件边界、状态位置、依赖关系和延迟执行点)
- 99.3 Lazy Activation Moves Work Toward User Intent(可恢复或延迟激活模型通常把部分客户端工作推迟到用户交互、组件可见或事件触发时,从而减少初始主线程压力)
- 99.4 Alternative Models Trade Simplicity for Startup Performance(resumability、islands、partial hydration、lazy activation 会改变代码加载、事件绑定、状态恢复和调试模型)
- 99.5 Framework Rendering Models Encode Different Assumptions About Interactivity(不同框架对“何时执行组件、何时绑定事件、何时加载代码、何时恢复状态”的假设不同,比较时需要超越 SSR/CSR 二分)
- 99.6 Resumability Still Depends on Browser Runtime Constraints(无论模型多先进,最终仍要受 JavaScript 下载、event loop、DOM、network、cache、memory 和浏览器安全边界约束)
Chapter 100: HTML Payload, Data Payload, JavaScript Payload, and Rendering Tradeoffs
- 100.1 Rendering Output Is Split Across Multiple Payloads(一个页面可能同时交付 HTML、RSC/data payload、JavaScript chunk、CSS、font、image 和 preload manifest)
- 100.2 More HTML Can Reduce Blank Screens but Increase Transfer and Server Work(发送更多 HTML 可以改善首屏可见性和 SEO,但也可能增加服务器渲染成本、传输体积和缓存复杂度)
- 100.3 More JavaScript Enables Interaction but Increases Startup Cost(客户端 JavaScript 提供丰富交互和状态逻辑,但会增加下载、解析、编译、执行、hydration 和长期内存成本)
- 100.4 Data Payload Shape Controls Client Work and Cache Behavior(过大的 JSON、重复数据、嵌套结构、序列化格式和缓存粒度会影响网络传输、解析成本、内存、stale state 和 invalidation)
- 100.5 CSS and Font Payloads Affect Rendering Readiness(CSS 和 font 可能阻塞或改变首屏渲染,导致 FOUC、FOIT、layout shift 或视觉不一致,因此也属于渲染模型权衡的一部分)
- 100.6 The Best Rendering Model Minimizes Total User-Visible Waiting(优化需要检查用户从请求到看见内容、分析内容、开始交互、完成任务的整体等待路径)
- 100.7 Payload Tradeoffs Must Be Measured(SSR、CSR、SSG、RSC、islands、resumability 的收益和成本会随设备、网络、页面类型、数据新鲜度和交互密度变化,必须用真实指标验证)
Chapter 101: Choosing a Rendering Model from User Experience and System Constraints
- 101.1 Content Freshness Determines Static vs Dynamic Pressure(内容更新频率、个性化程度、权限依赖、实时性和缓存容忍度,会决定页面更适合静态生成、请求时渲染还是客户端读取)
- 101.2 Interactivity Density Determines Client JavaScript Pressure(如果页面大部分都是交互组件,完全静态 HTML 带来的收益有限;如果页面主要是内容,少量 islands 或局部激活可能更合理)
- 101.3 SEO and Public Discovery Favor Stable HTML and Metadata(公开可发现页面通常需要稳定的 HTML、metadata、canonical、structured data 和可爬取内容)
- 101.4 Personalization and Security Favor Trusted Server Boundaries(用户权限、session、tenant、role、实验分组和敏感数据读取通常更适合放在可信 server 或 edge 边界,同时保留服务端可信控制)
- 101.5 Runtime and Hosting Constraints Limit What Is Practical(Node、edge、serverless、static hosting、CDN、数据库连接、cold start、streaming 支持和平台限制都会决定某种渲染模型是否可落地)
- 101.6 Failure Recovery Should Influence Rendering Choice(当数据加载失败、服务器超时、客户端脚本失败、缓存过期或权限变化时,渲染模型必须提供可解释的 fallback 和恢复路径)
- 101.7 Rendering Decision Is a Matrix(的渲染决策应同时考虑内容、交互、数据、缓存、SEO、安全、运行时、部署、成本和可观测性,再选择合适的框架默认模式)
Part 15: Forms, Actions, Progressive Enhancement, and Native Web Interaction
Chapter 102: Forms as the Original Web Mutation Boundary
- 102.1 Form Is the Native Write Path of the Web(form 是 Web 原生的写入路径,用户输入通过浏览器构造请求并提交给服务器,客户端框架状态管理只是增强路径的一部分)
- 102.2 Form Connects User Intent to HTTP Semantics(表单把用户点击、键盘提交、控件值、method、action、encoding 和 navigation 连接成一次明确的 HTTP 交互)
- 102.3 Submit Is a Browser-Owned Interaction Before It Is a Framework Event(提交表单首先是浏览器行为,然后才可能被 JavaScript 拦截、增强、转换为 fetch 或映射到 server action)
- 102.4 Mutation Boundary Starts at the Control(一次写入是从用户修改 input、选择文件、点击 submit、触发表单校验和构造请求开始)
- 102.5 Forms Preserve Functionality Across Capability Levels(在 JavaScript 未加载、网络较慢、框架失败或客户端增强不可用时,正确设计的表单仍然可以保留基础提交路径)
- 102.6 Modern Full-Stack Actions Are Repackaging an Old Web Primitive(server action、route action、form action、progressive enhancement 表面上是现代框架能力)
Chapter 103: Native Submission, Encoding, Redirect, and Browser Behavior
- 103.1 Native Submission Builds a Request from Form State(浏览器根据 form controls、name/value、method、action、enctype、target 等信息构造请求)
- 103.2 GET and POST Encode Different Interaction Intent(GET 更适合可分享、可缓存、可回放的查询状态;POST 更适合提交改变服务器状态的用户意图,但具体语义仍需服务器约束)
- 103.3 Encoding Defines How User Input Becomes Request Body or URL(application/x-www-form-urlencoded、multipart/form-data、text/plain、GET query 会生成不同请求体和 URL 形态)
- 103.4 Redirect-After-Post Protects Refresh and History Behavior(提交成功后重定向可以处理刷新页面导致的重复提交风险,也让浏览器历史栈和最终 URL 更符合用户预期)
- 103.5 Browser Autofill, Password Manager, and Input Memory Are Part of Form UX(表单需要和浏览器自动填充、密码管理、保存输入、键盘类型和历史恢复协作)
- 103.6 Native Submission Failure Has Built-In Recovery Expectations(网络失败、服务器错误、校验失败、返回错误页、用户后退重试等都是原生提交路径需要考虑的恢复语义)
Chapter 104: Constraint Validation, Form State, and User Feedback
- 104.1 Constraint Validation Is Browser-Level Pre-Submit Feedback(required、type、pattern、min、max、step、maxlength、自定义 validity 等约束让浏览器能在提交前给出基础反馈)
- 104.2 Native Validation Improves UX While Server Validation Establishes Trust(说明浏览器校验负责快速反馈,服务器验证负责信任边界和业务正确性)
- 104.3 Form State Includes More Than Field Values(form state 包括 dirty/touched、validity、pending、field error、submitter、disabled state、autofill 和 browser restoration)
- 104.4 Feedback Timing Changes User Trust(过早提示、过晚提示、提交后才反馈、输入时实时反馈、字段级反馈、表单级反馈都会影响用户分析和操作信心)
- 104.5 Disabled, Readonly, Hidden, and Required Have Different Semantics(disabled 控件不提交,readonly 控件通常仍可提交,hidden 控件不可见但可提交,required 参与校验;混用会造成数据缺失或安全误解)
- 104.6 Accessible Error Feedback Requires Semantic Connection(错误提示需要和对应字段通过 label、aria-describedby、aria-invalid、focus management 等方式建立语义连接,视觉颜色只能作为辅助信号)
- 104.7 Form Feedback Must Survive Enhancement Failure(即使 JavaScript 增强失败,用户也应该能看到可分析的提交结果、校验错误和下一步操作)
Chapter 105: Enhanced Forms, JavaScript Interception, and Progressive Enhancement
- 105.1 Enhancement Should Preserve the Native Submission Contract(JavaScript 可以拦截表单、局部更新、显示 pending 状态和调用 fetch,但应尽量保留原生 action、method、控件语义和可降级路径)
- 105.2 Interception Moves Responsibility from Browser to Application(拦截提交后,应用接管 navigation、history、focus、scroll、pending UI、abort、retry 和错误展示)
- 105.3 Fetch-Based Submission Changes Navigation Semantics(把表单提交改成 fetch 后,页面不会自然导航,URL、history、scroll、focus、refresh、back button 和错误显示都需要应用主动管理)
- 105.4 Progressive Enhancement Separates Base Path from Enhanced Path(基础路径应在没有 JavaScript 时可用,增强路径则提供局部刷新、optimistic UI、自动保存、实时校验和更顺滑的交互)
- 105.5 Enhanced Forms Need Abort and Race Control(用户重复提交、快速切换路由、修改字段后旧请求返回、组件卸载等场景都需要取消、去重、乱序保护和 stale result 检查)
- 105.6 Enhancement Is Successful Only When Failure Is Better Too(增强是让失败、等待、重试、回滚、权限拒绝和网络不稳定时也更可分析)
Chapter 106: Request-Scoped Actions and Redirect-After-Post
- 106.1 Action Is a Request-Scoped Mutation Handler(action 核心上是处理一次用户提交意图的 request-scoped mutation handler,它接收输入、验证权限、执行业务逻辑并返回结果或重定向)
- 106.2 Action Boundary Is Usually Closer to Route Than to Component(现代 full-stack framework 常把 action 绑定到 route、form 或 server function 边界)
- 106.3 Validation Must Run Inside the Trusted Boundary(客户端可以预校验,但 action 所在的可信服务器边界必须重新校验输入、权限、CSRF、业务规则和数据一致性)
- 106.4 Redirect-After-Post Converts Mutation Result into Navigation State(写入成功后通过 redirect 进入最终页面,可以处理重复提交风险,让结果页面拥有稳定 URL)
- 106.5 Action Result Can Be Data, Error, Redirect, or Revalidation Signal(action 可能只返回成功/失败,也可能返回字段错误、全局错误、重定向、缓存失效信号、toast 信息或需要重新加载的数据)
- 106.6 Request-Scoped Mutation Helps Avoid Long-Lived Client Inconsistency(把写入逻辑集中在请求边界,能减少客户端长期持有错误业务状态的机会,但仍需要处理 pending UI、失败恢复和缓存同步)
Chapter 107: Double Submit, Retry, Idempotency, and Native Interaction Safety
- 107.1 Double Submit Is a User Interaction and Network Problem(用户重复点击、浏览器重试、页面刷新、网络超时、后退重提都会导致重复提交风险,同时按钮禁用问题)
- 107.2 Pending State Prevents Accidental Re-Entry(提交中禁用按钮、显示 loading、锁定关键字段并控制 action 入口,可以减少用户无意重复发起写入)
- 107.3 Idempotency Keys Protect Server-Side Mutation Safety(对支付、订单、文件上传、批处理等高风险写入,客户端或服务器应使用 idempotency key 防止同一意图被重复执行)
- 107.4 Retry Must Distinguish Safe Retry from Dangerous Replay(网络失败后是否能重试,取决于服务器是否已经处理请求、操作是否幂等、是否有去重机制以及用户是否需要确认)
- 107.5 Back Button and Refresh Need Mutation-Aware Design(提交后浏览器刷新、后退、重新进入结果页时,系统应控制重复 mutation 风险,并清楚表达当前状态是已提交、处理中、失败还是可重试)
- 107.6 Native Interaction Safety Requires Server and Browser Cooperation(可靠的写入安全需要浏览器 UI、form 状态、客户端 pending、server action、数据库约束、redirect-after-post 和缓存刷新共同协作)
Chapter 108: Form and Action Models in Full-Stack Frameworks
- 108.1 Form and Action Align UI Intent with Request Semantics(form/action 模型天然把用户输入、提交意图、HTTP 请求、服务器处理和导航结果连成一条路径,因此适合现代 full-stack framework 重新包装)
- 108.2 Server Actions Reduce Client-Only Business Logic Drift(把 mutation 放回 server boundary,可以减少敏感逻辑、权限判断、数据库访问和业务规则在客户端重复实现或被绕过的风险)
- 108.3 Route Actions Localize Mutation to Application Flow(把 action 绑定到 route 或 layout 附近,可以让写入、错误、重定向、revalidation 和页面状态更贴合当前用户流程)
- 108.4 Progressive Enhancement Makes Framework Features More Robust(当框架 action 建立在原生 form 语义上时,即使 JavaScript 延迟、加载失败或网络不稳定,也更容易保留基础可用路径)
- 108.5 Form Actions Still Need Clear Cache and State Coordination(返回 form/action 需要结合上下文判断状态问题自动消失)
- 108.6 The Return to Forms Is a Return to Web Architecture(现代框架重新重视 form/action,是意识到 Web 原生 interaction model 本身就是经过长期验证的系统边界)
Part 16: Data Read Path, Loading Coordination, and Server-State Boundaries
Chapter 109: Data Read Path from User Intent to UI State
- 109.1 Data Reading Starts from User Intent(一次数据读取通常源于用户导航、搜索、筛选、打开弹窗、滚动分页、刷新页面或恢复会话,再映射到具体
fetch()调用) - 109.2 Read Path Crosses Browser, Network, Server, Cache, and Database Boundaries(一次读取会经过 user intent、route、fetch/loader、HTTP、auth、cache、database query、serialization 和 UI display)
- 109.3 The UI Usually Displays a Local Representation of Remote Truth(用户看到的数据多数是某个时刻的响应结果、缓存快照、派生状态或渐进加载片段)
- 109.4 Loading Is a State(loading 同时系统还无法确认数据、权限、错误或最终 UI 状态时的过渡状态)
- 109.5 Read Path Must Preserve Context During Waiting(等待数据时,系统应该尽量保留用户当前意图、输入、滚动、旧数据、占位内容或 fallback,并让界面保留上下文)
- 109.6 Read Path Failure Must Be User-Meaningful(数据读取失败可能来自网络、权限、资源不存在、服务器错误、缓存过期、schema 不匹配或请求被取消;错误反馈必须能让用户知道发生了什么以及能否恢复)
- 109.7 Data Reading Is the First Half of Full-Stack UI(现代 Web UI 的很多复杂度来自读取路径:什么时间读、在哪里读、谁缓存、谁拥有、谁刷新、谁显示等待和谁处理失败)
Chapter 110: Loader, Fetch, Server Component Data Access, and Query Function
- 110.1 Loader Ties Data Reading to Route and Navigation(loader 把数据读取绑定到路由和导航边界,使页面进入某个 URL 时能同时确定需要哪些数据、错误、redirect 和 loading 状态)
- 110.2 Fetch Is the Low-Level Browser and Runtime Request Primitive(Fetch 提供可编程请求边界,但它本身不解决缓存归属、状态管理、重试、去重、请求依赖、权限模型和 UI 反馈问题)
- 110.3 Server Component Data Access Moves Reading into Trusted Runtime(Server Component 可以在服务端读取数据,把某些查询逻辑和敏感访问留在可信 runtime 内)
- 110.4 Query Function Separates Remote Data Acquisition from UI Rendering(query function 把“如何获取远端数据”封装成可缓存、可重试、可失效、可复用的读取单元,使 UI 不必直接管理所有请求细节)
- 110.5 Same Data Can Be Read Through Different Boundaries(同一数据可以通过 loader、client query、server component、API route、edge cache 或 build-time output 读取)
- 110.6 Data Access Location Determines What Is Safe and Efficient(读取逻辑放在 browser、server、edge、build time 或 client cache 中)
- 110.7 Data Loading Abstraction Must Still Map to Real Request and Cache Behavior(无论框架把读取叫 loader、query、server component data access 还是 action-less fetch)
Chapter 111: Request Waterfall, Parallel Loading, and Dependency Ordering
- 111.1 Request Waterfall Happens When Later Reads Wait for Earlier Reads(当页面必须先加载 shell,再加载组件,再加载数据,或先等用户信息再加载业务数据时,就会产生 waterfall,放大网络延迟和用户等待)
- 111.2 Parallel Loading Requires Knowing Independent Dependencies Early(如果多个数据源彼此独立,系统应尽早并行发起请求;这要求路由、组件或 server boundary 能提前知道依赖关系)
- 111.3 Nested Routes and Nested Components Can Accidentally Create Serial Fetching(嵌套路由、组件内 fetch、effect 中请求和条件渲染可能把本可并行的读取变成层层串行)
- 111.4 Dependency Ordering Is Sometimes Necessary(并需要区分所有 waterfall 都是坏事;权限检查、tenant 解析、用户身份、feature flag、上游查询结果和参数验证可能确实需要先后顺序)
- 111.5 Prefetch Moves Read Work Before User Commitment(链接预取、hover 预取、viewport 预取、route manifest 预取和数据预取可以提前完成部分读取工作,但必须考虑浪费、权限、缓存污染和网络成本)
- 111.6 Abort and Deduplication Protect Navigation Responsiveness(用户快速切换路由或搜索条件时,旧请求应被取消、忽略或去重,保证新 UI 只接收当前结果)
- 111.7 Loading Coordination Is a Graph Problem(现代页面的数据读取是 URL、route、layout、component、server cache、client cache 和数据依赖共同形成的图)
Chapter 112: Server-Only Data, Secret Boundary, and Safe Data Exposure
- 112.1 Some Data Must Never Cross into the Browser(secret、internal id、permission rule、raw token、private audit data 和未裁剪业务字段应留在可信 runtime)
- 112.2 Server-Only Code Protects Access to Trusted Resources(数据库连接、admin SDK、payment key、filesystem、internal service client 都应放在 server-only module 或可信执行层)
- 112.3 Serialization Is the Exposure Boundary(server data 进入 HTML、JSON、RSC payload、hydration data、log 或 error report 时,就进入可被浏览器侧观察的边界)
- 112.4 Data Minimization Reduces Security and Cache Risk(客户端只应收到完成 UI 所需的数据;过度返回内部字段、权限信息、业务标记或用户隐私,会放大泄漏、缓存污染和调试困难)
- 112.5 Authorization Must Happen Before Data Shaping(服务端应先判断用户是否有权访问资源,再决定返回什么形状的数据;权限控制属于服务端信任边界)
- 112.6 Safe Exposure Depends on Runtime, Bundle, and Logging Boundaries(敏感数据可能通过响应、client bundle、source map、日志、analytics、error report、cache 或 HTML 注入数据泄漏)
- 112.7 Server-Only Boundary Must Be Enforced by Tooling and Review(server-only import guard、bundle analyzer、lint、code review、secret scanning 和 deployment test 共同保护边界)
Chapter 113: Query Cache, Server State, and Client-Side Data Ownership
- 113.1 Server State Is Owned Remotely but Observed Locally(server state 的权威来源在服务器或数据库,客户端只是观察和缓存它,因此它天然会过期、失效、被其他用户修改或被后台任务更新)
- 113.2 Query Cache Stores Snapshots with Freshness Rules(query cache 会记录 key、data snapshot、status、updatedAt、staleTime、gcTime、observer 和 refetch policy)
- 113.3 Cache Key Defines Data Identity(query key、URL、params、locale、auth state、tenant、feature flag 等共同决定缓存身份)
- 113.4 Background Refetch Separates UI Continuity from Data Freshness(后台刷新允许用户继续看到旧数据,同时系统尝试获取新数据;这改善体验,但需要清楚表达 refreshing、stale 和 error 状态)
- 113.5 Client Cache as a Structured System(客户端缓存属于用户可访问环境;敏感数据需要在服务端完成授权、裁剪和脱敏)
- 113.6 Cache Ownership Must Be Coordinated with Mutation(写入成功后,query cache 必须知道哪些数据需要更新、失效、重新获取或乐观回滚,否则 UI 会显示旧状态)
- 113.7 Server State Management Is a Consistency Strategy(使用 query cache 的核心是建立远端状态在客户端的可观察、可刷新、可失效、可恢复的一致性策略)
Chapter 114: Streaming Data, Deferred Data, Placeholder UI, and Progressive Rendering
- 114.1 Streaming Data Turns Reading into Incremental Delivery(streaming data 把读取拆成 initial chunk、deferred chunk、backpressure、late error、cache merge 和 UI reveal)
- 114.2 Deferred Data Splits Critical and Non-Critical Reads(关键数据用于生成首屏或主要交互,非关键数据可以延迟、并行或渐进加载,从而降低用户初始等待)
- 114.3 Placeholder UI Communicates Shape Before Data Completes(skeleton、fallback、占位图、局部 loading 和渐进 reveal 帮助用户分析页面结构,但如果尺寸或语义不稳定,也会造成 layout shift 和误解)
- 114.4 Progressive Rendering Requires Stable Boundaries(要逐步显示数据,系统必须明确哪些 layout、route、component 或 suspense boundary 可以先显示,哪些必须等待数据完成)
- 114.5 Streaming Failure Needs Late Error Handling(部分数据或 UI 已经显示后,后续 stream 失败需要局部错误、重试、降级内容和状态解释)
- 114.6 Incremental Data Must Coordinate with Cache and Revalidation(逐步返回的数据如何进入 cache、是否覆盖旧数据、何时认为完整、如何失效,都需要和缓存策略协调)
- 114.7 Progressive Data Is a User Experience Contract(渐进数据加载是承诺用户能更早分析页面、更早开始操作,并在等待期间不失去上下文)
Chapter 115: Read Path Failure Modes
- 115.1 Loading Hole Happens When UI Has No Meaningful Intermediate State(如果页面在数据未到达时只显示空白、闪烁、错位 skeleton 或无上下文 loading,用户会感到系统中断)
- 115.2 Overfetch Wastes Network, Parsing, Memory, and Privacy Budget(返回过多字段、过大列表、重复嵌套数据或未使用关系,会增加传输、解析、内存、缓存和隐私暴露成本)
- 115.3 Underfetch Creates Waterfall and Extra Round Trips(一次请求拿不到必要数据时,UI 需要继续发起后续请求,容易造成 waterfall、loading 嵌套和交互延迟)
- 115.4 Stale Data Breaks User Trust When It Looks Fresh(过期数据本身可能坏,但如果 UI 把旧数据展示得像最新状态,用户可能做出错误操作)
- 115.5 Authorization Drift Causes Data Disappearing or Leaking(用户权限变化、session 过期、tenant 切换、角色调整后,如果缓存或 loader 没有重新验证,会出现数据消失、误显示或越权泄漏)
- 115.6 Race Conditions Create Ghost UI(旧请求晚于新请求返回、重复路由切换、搜索防抖失控、组件卸载后更新状态,都会让 UI 显示不属于当前用户意图的数据)
- 115.7 Read Path Reliability Requires Observability(需要记录请求耗时、cache hit/miss、abort、retry、error type、stale state、用户路径和 server trace)
Part 17: Mutation Write Path, Consistency, Retry, and Failure Recovery
Chapter 116: Mutation Write Path from User Action to Durable State
- 116.1 Mutation Starts from User Intent(写入路径是从用户点击、提交表单、拖拽、编辑、删除、上传、确认支付或触发自动保存开始)
- 116.2 Write Path Crosses More Boundaries Than Read Path(写入会穿过 user intent、form/action、validation、auth、transaction、side effect、cache invalidation 和 UI recovery)
- 116.3 Durable State Is the Difference Between UI Change and Real Mutation(服务器、数据库或持久化系统确认状态变化后,mutation 才成为系统事实)
- 116.4 Mutation Must Preserve User Intent Across Failure(网络失败、权限过期、校验失败、服务器错误、数据库冲突或页面导航中断时,系统应尽量保留用户意图、输入内容和恢复路径)
- 116.5 Mutation Result Must Return to the Correct UI Context(写入结果需要回到发起它的页面、表单、列表、详情、toast、modal 或缓存边界;如果用户已经导航离开,结果处理必须识别 ghost update 风险)
- 116.6 Write Path Is Where Trust, Consistency, and Experience Meet(mutation 同时涉及用户体验、业务正确性、安全权限、事务一致性和缓存同步,是 full-stack Web 中最容易出真实事故的路径之一)
Chapter 117: REST, RPC, GraphQL, and Server Function Mutation Paths
- 117.1 REST Mutation Uses Resource and Method Semantics(REST 风格写入通常通过 POST、PUT、PATCH、DELETE 等 method 表达创建、替换、局部修改和删除,适合资源边界清晰的系统)
- 117.2 RPC Mutation Uses Action-Oriented Call Semantics(RPC 风格写入更接近调用某个命令或函数,例如
createOrder、publishPost、approveInvite,适合业务动作比资源形态更明确的场景) - 117.3 GraphQL Mutation Uses Schema-Defined Operation Shape(GraphQL mutation 通过 schema 定义输入、返回字段和 resolver 行为,使客户端能精确声明写入后的返回形状)
- 117.4 Server Function Mutation Moves Call Boundary into Framework Semantics(server function / server action 把客户端调用和服务端执行包装成框架级边界,减少手写 API 层,但仍必须处理验证、权限、事务、重试和缓存失效)
- 117.5 Mutation Style Changes Error Shape and Recovery Strategy(REST、RPC、GraphQL、Server Function 的错误表达、状态码、字段错误、业务错误、重定向和重试语义不同,会影响 UI 如何恢复)
- 117.6 Different Mutation Paths Still Share the Same System Responsibilities(无论外层写法是 REST、RPC、GraphQL 还是 Server Function,系统都必须回答输入如何验证、权限如何判断、状态如何持久化、缓存如何更新、失败如何恢复)
Chapter 118: Client Validation, Server Validation, and Runtime Schema Enforcement
- 118.1 Client Validation Improves Feedback but Cannot Establish Trust(客户端校验负责更快提示格式错误、必填缺失、长度限制和交互问题;安全与业务正确性由服务端校验兜底)
- 118.2 Server Validation Is the Trusted Boundary(所有写入数据都必须在服务端重新验证,包括类型、格式、权限、业务约束、资源归属、CSRF、速率限制和幂等性)
- 118.3 Runtime Schema Turns Unknown Input into Checked Data(Zod、Valibot、JSON Schema 等 runtime schema 把 unknown body、form data、params 和 third-party callback 转成可信输入)
- 118.4 Field Errors and Business Errors Need Different UI Shapes(字段错误适合回到具体 input,业务错误可能属于整个 form、modal、流程或资源状态;错误形态会影响反馈位置和恢复路径)
- 118.5 Validation Should Happen Before Irreversible Side Effects(在扣款、发邮件、写数据库、上传文件、调用第三方服务之前,应尽量完成输入、权限和业务规则校验,减少回滚复杂度)
- 118.6 Schema Enforcement Must Stay Consistent Across Client, Server, and Database(客户端 schema、服务端 schema、数据库约束和 API contract 如果不一致,会导致前端通过但后端失败、后端通过但数据库失败,或错误信息无法对齐)
Chapter 119: Optimistic UI, Pending State, Rollback, and Conflict Resolution
- 119.1 Pending State Makes the Mutation Visible Before It Completes(pending state 告诉用户系统已经接收意图但尚未确认结果,它可以表现为按钮禁用、进度、临时列表项、toast、loading row 或表单锁定)
- 119.2 Optimistic UI Predicts Success to Reduce Perceived Latency(optimistic UI 在服务器确认前先更新界面,让用户感到操作即时完成,适合失败率低、回滚成本可控的交互)
- 119.3 Optimistic Update Must Remember the Previous State(为了失败时恢复,系统必须保存旧数据、patch、mutation context 或可逆操作,否则 rollback 会破坏 UI 一致性)
- 119.4 Rollback Is a User Experience Problem(回滚需要恢复数据,并解释刚才看似成功的操作为何被撤销,减少用户误解、重复操作和信任损失)
- 119.5 Conflict Resolution Handles Concurrent Writes and Stale Assumptions(当多个用户、多个标签页、后台任务或离线队列同时修改同一资源时,系统需要版本号、etag、last-write-wins、merge、人工确认或 CRDT 等策略)
- 119.6 High-Risk Mutations Need Confirmation(支付、删除不可恢复资源、权限变更、复杂事务、法律确认、库存扣减等高风险写入应优先保证确认和可恢复性)
- 119.7 Optimistic UI Must Be Coupled with Invalidation or Reconciliation(乐观更新后的 UI 仍需要通过重新拉取、server echo、cache reconciliation 或 subscription 确认最终状态,防止预测结果长期偏离真实数据)
Chapter 120: Idempotency, Retry, Race Condition, and Double Write Prevention
- 120.1 Retry Needs Idempotency to Prevent Duplicate Mutation(网络超时、浏览器重试、用户重复点击、serverless timeout 或移动网络切换时,客户端需要用幂等性判断服务器处理状态,控制重复订单、重复付款和重复创建风险)
- 120.2 Idempotency Key Represents One User Intention Across Attempts(idempotency key 用一个稳定标识把多次请求归并为同一次用户意图,使服务器能够识别重复提交并返回一致结果)
- 120.3 HTTP Method Idempotency as a Structured System(PUT / DELETE 在 HTTP 语义上通常被视为幂等,但具体业务仍可能因为副作用、日志、通知、异步任务或实现错误而不幂等;POST 也可以通过业务 key 设计成幂等)
- 120.4 Race Conditions Happen When Writes Arrive Out of Assumed Order(多个写入请求、自动保存、快速点击、跨标签页修改、离线同步和实时协作都可能让服务器接收到的顺序与用户心理顺序不同)
- 120.5 Double Write Prevention Requires Client and Server Cooperation(客户端禁用按钮只能减少重复触发,防止重复写入需要服务端幂等性、唯一约束、事务锁、版本检查或冲突检测)
- 120.6 Retry Policy Must Classify Failure Types(超时、5xx、网络断开、409 冲突、422 校验失败、401 过期、403 拒绝、429 限流都需要不同重试、回滚或用户确认策略)
- 120.7 Safe Mutation Design Treats Uncertainty as Normal(可靠写入架构把重复请求、重复处理、响应丢失、用户重复点击和重试作为默认场景设计)
Chapter 121: Mutation Result, Cache Invalidation, and UI Consistency
- 121.1 Mutation Result Is the Bridge Back to the UI(写入完成后,服务器返回的结果决定 UI 显示成功、字段错误、业务错误、重定向、更新后的资源、后台处理中状态或需要重新加载的数据)
- 121.2 Server Echo Can Reconcile Optimistic State(服务器返回最终资源状态、版本号、派生字段、权限变化或规范化数据,可以帮助客户端把乐观预测和真实状态对齐)
- 121.3 Cache Invalidation Defines What Is No Longer Trustworthy(invalidation 需要说明哪些 query key、route segment、server cache、CDN cache、derived count 和 search result 过期)
- 121.4 Over-Invalidation Wastes Work, Under-Invalidation Shows Stale UI(失效范围过大导致重复请求和性能浪费,失效范围过小则会让用户看到旧列表、旧详情、旧权限或错误计数)
- 121.5 Mutation May Affect Multiple Views of the Same Resource(创建评论可能影响文章详情、评论列表、用户动态、通知数、搜索结果和统计数据;写入路径必须知道同一事实在多个 UI 位置的投影)
- 121.6 Revalidation Timing Changes User Experience(可以在写入后立即 refetch、后台刷新、等待导航、由服务器 push、由缓存标签失效或延迟到用户重新访问,不同策略影响反馈速度和一致性)
- 121.7 UI Consistency Requires a Shared Data Identity Model(如果列表、详情、缓存、URL、数据库记录和 API response 对同一资源没有统一身份,mutation 后很难可靠更新所有相关 UI)
Chapter 122: Write Path Failure Modes and Recovery Design
- 122.1 Validation Failure Should Preserve User Input and Explain Fixes(输入校验失败时,系统应该保留用户填写内容,标记具体字段或业务规则,并说明如何修复,并保留清晰字段反馈)
- 122.2 Auth Failure Requires Reauthentication while Preserving Intent(session 过期或权限变化时,系统应尽量保留用户提交意图,在重新登录或重新授权后恢复操作)
- 122.3 Conflict Failure Needs a Human-Understandable Merge Path(数据冲突需要超越 409 状态码;系统需要解释资源已变化、展示差异、允许覆盖、合并、放弃或重新提交)
- 122.4 Partial Failure Requires Compensation or Explicit State(文件上传成功但数据库写入失败、支付成功但订单创建失败、邮件发送失败但记录已保存等情况,需要补偿操作、后台修复或明确中间状态)
- 122.5 Timeout Separates Client Waiting from Server Execution(说明客户端超时、服务器执行、幂等确认和状态查询之间的恢复关系)
- 122.6 Offline and Background Failure Need Queues and User Trust(离线提交、后台同步、草稿保存和延迟上传都需要队列状态、重试策略、冲突处理和用户可见的任务状态)
- 122.7 Recovery Design Completes the Mutation Architecture(写入架构不完整的标志是失败、重复、冲突、超时、取消和部分成功时仍能保护数据与用户意图)
Part 18: API Contracts, RPC, Schema, and Interoperability Boundaries
Chapter 123: API Boundary as a Contract Between Independent Runtimes
- 123.1 API Boundary Exists Because Client and Server Run Separately(说明不同运行时、权限、生命周期和部署边界为何需要明确 API contract)
- 123.2 Contract Defines What Can Cross the Boundary(contract 定义输入 schema、输出 shape、error format、auth requirement、version、side effect 和 compatibility guarantee)
- 123.3 Independent Deployment Makes Contract Stability Critical(客户端和服务器经常需要区分同时部署,旧客户端可能调用新服务,新客户端也可能遇到旧缓存或旧边缘节点,因此 contract 必须能承受版本漂移)
- 123.4 Serialization Turns Runtime Objects into Transferable Representations(函数、数据库对象、class instance、Date、BigInt、Map、File、Stream、Error 等运行时对象需要转换成可传输表示)
- 123.5 Error Contract Is Part of the API(字段错误、业务错误、权限错误、认证过期、限流、冲突、服务不可用和未知错误都需要稳定表达,否则客户端无法可靠恢复)
- 123.6 API Boundary Is Also a Trust Boundary(所有进入服务端的输入都按不可信数据处理,所有返回客户端的数据都经过授权、裁剪和脱敏,类型安全只承担结构约束)
- 123.7 Good API Design Makes Failure and Evolution Predictable(好的 API contract 同时成功路径优雅,还要让错误、重试、分页、取消、幂等、版本升级和兼容迁移都可预测)
Chapter 124: REST Resource Semantics and HTTP-Aligned Interface Design
- 124.1 REST Aligns API Shape with Resources and HTTP Semantics(REST 风格接口把 URL 视为资源标识,把 HTTP method 视为操作语义,使浏览器、代理、缓存、日志和工具都能分析一部分行为)
- 124.2 Resource Identity Should Be Stable and Meaningful(资源 URL 应该稳定表达用户、文章、订单、评论、文件、组织、租户等实体或集合,让 action endpoint 也保持明确资源语义)
- 124.3 Method Semantics Influence Safety, Idempotency, and Retry(GET、POST、PUT、PATCH、DELETE 的语义会影响缓存、重试、幂等性和中间层行为;错误使用 method 会让系统难以推断操作风险)
- 124.4 Status Codes Are Part of the Contract Surface(200、201、204、301、304、400、401、403、404、409、422、429、500、503 等状态码应稳定表达结果类型,并为失败类型选择稳定状态码)
- 124.5 Representations Shape Resource Exposure(说明 REST response 如何裁剪、组合、链接和隐藏资源内部结构)
- 124.6 REST APIs Need Pagination, Filtering, Sorting, and Partial Updates as First-Class Design(列表、搜索、分页、排序、字段选择、PATCH、bulk operation 等是资源接口长期可用性的核心)
- 124.7 REST Works Best When HTTP Infrastructure Can Participate(用 method、status、cache header、ETag 和 content negotiation 接入 HTTP 基础设施)
Chapter 125: GraphQL Query Shape, Schema, Resolver, and Execution Boundary
- 125.1 GraphQL Makes the Schema the Central Contract(GraphQL schema 集中定义 type、query、mutation、field、resolver、directive、deprecation 和 client selection set)
- 125.2 Client Controls Query Shape Within Server-Defined Limits(GraphQL 允许客户端声明需要哪些字段,减少 overfetch 或 underfetch)
- 125.3 Resolver Turns Field Selection into Backend Execution(GraphQL 查询看似是字段选择,实际会进入 resolver 执行路径,可能触发数据库查询、服务调用、权限判断、缓存读取和批处理)
- 125.4 N+1 and Resolver Waterfall Are Execution Problems(GraphQL 的灵活查询形状可能造成 resolver 层级瀑布、重复查询和 N+1 问题,需要 dataloader、批处理、预加载和查询规划控制)
- 125.5 GraphQL Errors Can Be Partial and Structured(GraphQL response 可能同时包含部分 data 和 errors,这种错误模型不同于普通 REST status code,需要客户端明确处理字段级失败和整体失败)
- 125.6 GraphQL Cache Strategy Depends on Identity and Normalization(GraphQL 客户端缓存通常需要通过 id、typename、field arguments 和 normalized entity 识别数据)
- 125.7 GraphQL Is an Execution Boundary(GraphQL 把查询形状、类型系统、resolver 执行、权限、缓存和客户端数据需求压缩到同一个 contract 中)
Chapter 126: RPC, tRPC, Server Function, and Type-Safe Call Boundary
- 126.1 RPC Treats API as Calling a Remote Procedure(RPC 把跨网络交互表达为调用远端函数或方法,例如
createPost、getUserProfile、submitOrder,更接近业务动作和服务接口) - 126.2 Type-Safe RPC Reduces Compile-Time Contract Drift(tRPC 或类似工具通过共享 TypeScript 类型、推导输入输出和生成 client helper,减少客户端和服务端在编译期的 contract 不一致)
- 126.3 Runtime Validation Is Still Required(TypeScript 类型会在运行时消失,API body、URL params、third-party data 和 database result 仍需要 runtime validation)
- 126.4 Server Functions Collapse API Boilerplate While Keeping Boundary Duties(说明 server function 减少 endpoint 样板后仍要承担序列化、权限、错误、缓存和版本责任)
- 126.5 RPC Contracts Are Often Coupled to Application Code Structure(RPC 方法常与服务端函数、模块和业务命名强相关,开发效率高,但如果缺少边界设计,也会让客户端过度依赖服务端内部结构)
- 126.6 Type Safety Covers Code Shape, Contract Strategy Covers Longevity(说明类型安全 RPC 的适用边界,以及公开 API、第三方集成和长期兼容需要的 contract 策略)
- 126.7 RPC Works Best When Boundary Ownership Is Clear(RPC 需要明确调用者、调用语义、失败表达、版本迁移和远程暴露范围)
Chapter 127: OpenAPI Schema Contracts and Client Generation
- 127.1 OpenAPI Turns HTTP APIs into Machine-Readable Contracts(OpenAPI 用结构化文档描述 HTTP API 的 path、method、parameter、request body、response、schema、auth 和错误)
- 127.2 Schema-First Design Makes Contract Reviewable Before Implementation(schema-first 让团队在实现前讨论 API shape、数据模型、错误格式和版本策略,减少实现之后才发现 contract 不稳定的问题)
- 127.3 Code-First Design Derives Contract from Existing Implementation(code-first 可以降低重复定义成本,从 handler、decorator、type、schema 或 framework route 中生成 OpenAPI)
- 127.4 Client Generation Moves Contract into Developer Workflow(根据 OpenAPI 生成 client、type、mock、test 和 documentation,可以减少手写调用错误,但生成代码质量和版本管理也会成为维护成本)
- 127.5 Runtime Validation Enforces Contract at the Boundary(请求参数、body、header、response 都可以通过 schema 在运行时检查,使 API contract 同时可执行边界)
- 127.6 Contract Tests Prevent Documentation from Drifting Away from Reality(OpenAPI 文档、实际服务、生成客户端和测试需要通过 contract test、schema validation 和 CI 检查保持一致)
- 127.7 Machine-Readable Contracts Enable Ecosystem Interoperability(OpenAPI 让网关、mock、SDK、测试、安全扫描、监控和第三方集成可以共同分析 API)
Chapter 128: BFF, Route Handler, Middleware, and Frontend-Specific Backend
- 128.1 BFF Exists Because Generic APIs Miss Frontend-Specific Needs(说明 BFF 如何服务页面、设备、产品线和用户流程的数据形状)
- 128.2 BFF Aggregates, Shapes, and Protects Data for a Specific Client(BFF 可以组合多个后端服务、裁剪字段、处理权限、隐藏内部拓扑、适配客户端需求,并减少浏览器直接访问复杂内部服务)
- 128.3 Route Handlers Turn Framework Routes into Server Boundaries(现代 full-stack framework 的 route handler 可以在应用路由附近处理请求、生成响应、访问 secret、调用数据库或代理后端服务)
- 128.4 Middleware Runs Before the Final Handler and Changes Request Flow(middleware 可以做身份检查、重定向、A/B test、locale、header 改写、rate limit、日志和缓存判断,但也会增加请求路径隐式复杂度)
- 128.5 BFF Requires Clear Responsibility and Dependency Direction(说明 BFF 需要清楚职责、依赖方向和领域边界)
- 128.6 BFF Boundary Helps Separate Public Contract from Internal Service Contract(面向浏览器的 contract 可以保持简单稳定,而内部服务 contract 可以独立演进;BFF 负责映射、裁剪和兼容)
- 128.7 BFF Design Must Balance Convenience and Long-Term Ownership(BFF 让前端交付更快,但也要明确谁维护、谁监控、谁负责安全、如何测试、如何处理版本和故障传播)
Chapter 129: Contract Drift, Versioning, Backward Compatibility, and Migration
- 129.1 Contract Drift Happens When Code and Assumptions Evolve Separately(当客户端、服务器、文档、schema、mock、测试和缓存中的 API 假设产生差异时,就会出现 contract drift)
- 129.2 Backward Compatibility Protects Independently Deployed Clients(Web 客户端、移动端、第三方集成、旧浏览器缓存、Service Worker 缓存和 CDN 节点可能长期保留旧调用方式,API 需要同时服务新旧部署版本)
- 129.3 Additive Change Is Safer Than Breaking Change(新增可选字段、新 endpoint、新 enum 值和兼容参数通常比删除字段、改类型、改语义、改错误形状更容易平滑上线)
- 129.4 Versioning Can Be URL-Based, Header-Based, Schema-Based, or Capability-Based(版本可以放在 path、header、media type、schema field、feature capability 或 server function deployment cadence 中)
- 129.5 Deprecation Requires Communication and Observability(废弃字段或 endpoint 需要文档、warning、usage telemetry、迁移窗口、错误预算和最终移除策略,再执行最终移除)
- 129.6 Migration Often Needs Compatibility Layers(大型系统迁移可能需要 adapter、BFF、dual write、shadow read、response translation、schema bridge 和灰度发布)
- 129.7 A Stable Contract Is an Engineering Product(API contract 是需要设计、评审、测试、监控、版本管理和迁移治理的工程产品)
Part 19: Identity, Session, Authorization, and Application Security
Chapter 130: Web Identity Model and Authentication Boundary
- 130.1 Identity Is a Claim(Web 身份是系统对“当前请求代表谁”的判断,包括用户、设备、会话、组织、租户、角色和认证强度)
- 130.2 Authentication Establishes Who the User Is(authentication 的核心是验证用户身份,例如密码、短信、邮箱链接、Passkey、OAuth/OIDC、企业 SSO 或多因素认证)
- 130.3 Authorization Decides What the User May Do(authorization 判断某个已识别主体是否可以读取、创建、修改、删除或执行某个资源操作)
- 130.4 Identity Boundary Must Be Rebuilt on Every Request(HTTP 请求天然离散,每次请求都需要从 cookie、session、token 或其他 credential 中恢复身份上下文)
- 130.5 Browser Identity State and Server Identity State Must Agree(浏览器可能持有 cookie、token、local state、query cache 和 UI 登录态)
- 130.6 Authentication Failure Is a User Flow(登录失败、会话过期、MFA 失败、SSO 回调失败或账户锁定,都需要变成可分析、可恢复、可审计的用户流程)
- 130.7 Web Identity Is a Cross-Boundary State Machine(完整身份系统跨越浏览器、认证服务、应用服务器、数据库、cookie、redirect、token、缓存和权限检查,必须按状态机分析)
Chapter 131: Cookie, Session, Token, JWT, and Session Refresh Path
- 131.1 Cookie Is a Browser-Attached Request State Mechanism(cookie 会由浏览器在匹配 domain、path、secure、SameSite 等条件时自动附加到请求中,因此它天然适合表达浏览器到服务器的会话状态)
- 131.2 Server Session Keeps Authority on the Server Side(server-side session 通常只把 session id 放在 cookie 中,的用户状态、权限、过期时间和撤销逻辑保存在服务端,使服务端更容易集中控制)
- 131.3 Token-Based Auth Moves More State into Portable Credentials(access token、refresh token、JWT 等机制把部分身份或授权信息编码进 credential,使其可被 API、移动端、第三方服务或分布式系统使用)
- 131.4 JWT Is a Token Format(JWT 只是表达 claims、签名和过期等信息的一种格式,是否安全取决于签名验证、过期策略、issuer、audience、存储位置、撤销机制和权限模型)
- 131.5 Refresh Path Extends Session with Reduced Full Login(refresh token、silent refresh、session rotation、sliding expiration 等机制可以减少重新登录频率)
- 131.6 Session Storage Location Changes Threat Model(credential 放在 HttpOnly cookie、localStorage、memory、IndexedDB 或 native container 中)
- 131.7 Session Refresh Failure Requires Intent Preservation(说明 session 过期后的表单意图保存、重新认证和流程恢复路径)
Chapter 132: OAuth, OIDC, Third-Party Login, and Redirect-Based Identity Flow
- 132.1 OAuth Is Delegated Authorization(OAuth 2.0 的核心是授权第三方客户端访问资源,需要区分单独的身份认证协议;把 OAuth 当登录使用时需要分析它解决和不解决的问题)
- 132.2 OpenID Connect Adds an Identity Layer on Top of OAuth(OpenID Connect 在 OAuth 2.0 之上加入 ID Token、claims、issuer、subject 等身份语义)
- 132.3 Redirect-Based Login Crosses Browser, Provider, and Application Boundaries(第三方登录通常通过浏览器跳转到身份提供商,再回调应用;这个过程跨越 origin、cookie、state、code、session 和 redirect URI 边界)
- 132.4 State, Nonce, PKCE, and Redirect URI Protect the Flow(state 防 CSRF,nonce 防 token replay,PKCE 保护授权码交换,redirect URI 限制回调目标;这些是流程安全的核心)
- 132.5 Provider Identity Must Be Mapped to Application Identity(第三方 provider 返回的 subject、email、profile 需要映射到应用内部用户,并处理账号绑定、重复邮箱、组织归属、禁用账户和权限关系)
- 132.6 Third-Party Login Failure Has Many Partial States(用户取消授权、provider 错误、回调丢失、code 过期、state 不匹配、账号未绑定、权限不足,都需要明确错误页和恢复路径)
- 132.7 SSO Turns Authentication into Federation Architecture(企业 SSO、OIDC、SAML、多租户身份提供商会让登录从单应用问题变成跨组织、跨域名、跨策略的 federation 架构问题)
Chapter 133: CSRF, XSS, CORS, SameSite, Secure, and HttpOnly in Application Context
- 133.1 Application Security Must Combine Browser Rules and Server Checks(浏览器安全策略能降低风险,但应用仍必须在服务端进行输入校验、权限判断、CSRF 防护、输出转义和敏感操作保护)
- 133.2 CSRF Exploits Browser-Attached Credentials(CSRF 利用浏览器会自动携带 cookie 的特性,诱导用户在已登录状态下向目标站点发起非预期请求)
- 133.3 XSS Turns Trusted Pages into Attacker Execution Environments(XSS 让攻击者脚本在受信任页面中运行,可以读取页面状态、发起请求、修改 DOM、窃取非 HttpOnly 数据或诱导用户操作)
- 133.4 HttpOnly and Secure Reduce Cookie Exposure Within a Larger Threat Model(说明 cookie 属性如何降低暴露,并把 XSS、权限和操作确认放回完整威胁模型)
- 133.5 SameSite Changes Cross-Site Cookie Behavior in Auth Flows(SameSite 能降低 CSRF 风险,但也会影响第三方登录、支付回跳、跨站嵌入和多域产品,因此需要结合具体流程设计)
- 133.6 CORS as a Structured System(CORS 控制浏览器是否把跨源响应暴露给脚本,服务端鉴权仍验证当前请求主体是否有权访问资源)
- 133.7 Security Headers and Application Logic Must Be Designed Together(CSP、HSTS、CORS、COOP/COEP、cookie attributes、permission policy 要和 auth、routing、embedding、asset pipeline 对齐)
Chapter 134: Middleware, Route Guard, API Guard, and Request Authorization
- 134.1 Authorization Belongs on the Trusted Side of the Boundary(页面隐藏按钮或前端路由拦截只能改善体验,的权限判断必须发生在服务端、API、数据库策略或可信运行时中)
- 134.2 Middleware Handles Early Request Decisions(middleware 适合处理 auth gate、redirect、locale、A/B test、tenant resolution、header rewrite 和 early rejection)
- 134.3 Route Guard Protects Page-Level Access(route guard 判断用户能否进入某个页面或路由段,常用于登录要求、角色要求、组织成员检查和 onboarding 状态判断)
- 134.4 API Guard Protects Operation-Level Access(API guard 必须判断用户是否能执行某个具体操作,例如编辑某篇文章、删除某个订单、查看某个项目或导出某份报表)
- 134.5 Authorization Must Include Resource Ownership(只检查用户是否登录或是否有角色通常不够,还要检查资源是否属于当前用户、组织、租户或授权范围)
- 134.6 Guard Placement Determines Failure Shape(guard 放在 middleware、route loader、API handler、server action、database query 时,用户看到的失败状态不同)
- 134.7 Authorization Logic Needs Central Policy and Local Context(权限系统既需要集中可审计的策略模型,也需要结合具体资源、请求上下文和业务状态的局部判断)
Chapter 135: Role, Permission, Tenant, Organization, and Feature Flag Boundary
- 135.1 Role Is a Coarse-Grained Identity Attribute(role 常用于表达用户在系统中的大致身份,例如 admin、editor、member、viewer,但角色本身通常不足以表达所有资源级权限)
- 135.2 Permission Represents Operation-Level Capability(permission 更接近“能做什么”,例如
post:update、invoice:read、user:invite,适合细粒度控制 API、UI 和后台任务) - 135.3 Tenant and Organization Define Data Boundaries(多租户系统中,tenant / organization 决定数据隔离、成员关系、计费、配置、域名和权限范围,是比单个用户更高层的安全边界)
- 135.4 Feature Flags Are Runtime Capability Boundaries(feature flag 同时开关 UI,也可能控制 API、数据库字段、实验路径、权限策略和灰度发布;错误设计会造成用户看到功能但无法执行)
- 135.5 UI Capability Must Derive from Trusted Policy(前端是否显示按钮、菜单、页面和入口,应来自可信权限模型的派生,由可信策略驱动前端展示)
- 135.6 Authorization Models Must Handle Change Over Time(用户被移出组织、角色改变、flag 关闭、订阅过期、租户被冻结时,缓存、session、UI 和 API 必须重新评估权限)
- 135.7 Permission Architecture Is Data Architecture(权限需要区分独立模块,它与用户表、组织表、资源归属、关系模型、数据库查询、缓存键和审计日志紧密相关)
Chapter 136: Secret Boundary Across Browser, Server, Edge, Build Time, and Deployment
- 136.1 Secret Must Never Be Treated as Ordinary Configuration(secret 是受权限、作用域、轮换、审计和泄漏响应约束的高风险运行时资源)
- 136.2 Browser Bundle Is a Public Artifact(任何打进 client bundle、source map、inline script、public env、network response 或静态文件的内容)
- 136.3 Server Runtime Can Hold Secrets but Must Limit Exposure(server runtime 可以读取 secret,同时需要控制日志、error report、serialization、child process、third-party SDK 和响应输出)
- 136.4 Edge Runtime Secret Scope May Differ from Origin Server(edge worker、middleware、serverless region 可能拥有不同 secret 集、权限和复制范围)
- 136.5 Build-Time Environment Capture Can Leak or Freeze Values(构建阶段读取的环境变量可能被内联到产物中,也可能在部署后无法变化;必须区分 build-time config、runtime config 和 public config)
- 136.6 Rotation, Revocation, and Audit Are Part of Secret Design(secret 需要能轮换、撤销、追踪使用、限制作用域和最小权限;如果无法轮换,泄漏后的恢复成本会很高)
- 136.7 Secret Boundary Should Be Enforced by Tooling(secret scanning、public env prefix、server-only guard、bundle analyzer、CI policy 和权限分级共同保护 secret boundary)
Chapter 137: Auth Failure, Session Expiry, Reauthentication, and Recovery Experience
- 137.1 Auth Failure Happens in the Middle of User Work(身份失败可能发生在提交表单、上传文件、切换路由、后台刷新、打开 WebSocket 或执行 server action 过程中)
- 137.2 Session Expiry Must Preserve Context and Intent(会话过期时,应尽量保留用户当前 URL、表单草稿、pending action、scroll、modal 和导航上下文,重新认证后回到原流程)
- 137.3 Reauthentication Is Required for Sensitive Operations(修改密码、支付、删除组织、导出数据、变更权限等敏感操作可以要求重新认证或 MFA,以提高操作可信度)
- 137.4 Background Refresh Failure Requires Scoped Recovery(说明后台刷新失败时如何区分可见数据、可继续操作和重新登录范围)
- 137.5 Logout Must Clear More Than the Server Session(logout 需要清理 cookie、client cache、local storage、service worker state、WebSocket、memory state 和跨标签同步)
- 137.6 Auth Recovery Must Be Consistent Across Pages and APIs(页面路由、API 请求、server component、middleware、client fetch、WebSocket 和后台任务需要一致处理身份失败)
- 137.7 Good Auth UX Is Security Architecture Made Visible(用户看到的登录、过期、重试、权限拒绝和退出流程,实际上是安全边界设计在产品体验中的可见表现)
Part 20: Persistence, Domain Logic, File Storage, and Data Stability
Chapter 138: Database Boundary in Web Applications
- 138.1 Database Boundary Is Where Temporary Interaction Becomes Durable State(用户输入、表单提交、API mutation 和后台任务只有进入数据库或持久化系统后,才从临时交互变成可恢复、可审计、可共享的系统状态)
- 138.2 Web Applications Usually Treat the Database as the Source of Truth(说明浏览器副本、后端状态和数据库权威事实之间的关系)
- 138.3 Database Access Must Cross a Trusted Runtime Boundary(浏览器侧请求应通过 server/API/action 边界进入数据库访问层,并接受 auth、tenant、validation 和 query shaping)
- 138.4 Query Shape Defines What the UI Can Know(数据库查询决定页面能看到哪些字段、关联、聚合、权限过滤和排序结果;query shape 会直接塑造 UI 状态和加载路径)
- 138.5 Database Boundary Is Also a Security Boundary(每次数据读取或写入都结合身份、租户、权限、资源归属和字段级暴露策略,再返回浏览器可见数据)
- 138.6 Persistence Errors Become User-Visible Consistency Problems(数据库超时、连接耗尽、唯一约束冲突、事务失败、死锁、复制延迟或迁移不一致,都会表现为提交失败、旧数据、重复记录或页面状态错乱)
- 138.7 Web Data Architecture Starts by Defining the Source of Truth(设计 Web 数据系统时,首先要明确哪些事实由数据库拥有,哪些由缓存派生,哪些由浏览器暂存,哪些由第三方系统负责)
Chapter 139: SQL, NoSQL, ORM, Query Builder, and Type-Safe Data Access
- 139.1 SQL and NoSQL Reflect Different Data Modeling Assumptions(SQL 更强调关系、约束、事务和查询表达能力;NoSQL 系统可能更强调文档、键值、列族、图结构、水平扩展或特定访问模式)
- 139.2 ORM Maps Application Objects to Persistent Structures(ORM 试图把应用层对象、模型、关系和方法映射到数据库表、字段和查询,但这种映射会隐藏 SQL 成本、加载策略和事务边界)
- 139.3 Query Builder Keeps Query Shape More Explicit(query builder 通常比 ORM 更接近 SQL 或数据库查询结构)
- 139.4 Type-Safe Data Access Reduces Interface Drift(类型安全的数据访问可以让 schema、query result、输入参数和应用代码在编译期保持更一致,减少字段拼写错误和数据 shape 漂移)
- 139.5 Data Access Abstraction Still Exposes Database Realities(说明 ORM、query builder、raw SQL、resolver 和 service 仍要面对索引、事务、约束和查询计划)
- 139.6 Data Access Tools Should Match Ownership and Complexity(简单 CRUD、复杂报表、多表事务、实时查询、全文搜索、权限过滤和多租户隔离,对数据访问工具的要求不同,选择依据应来自查询复杂度和所有权边界)
- 139.7 The Data Layer Is a Contract Between Domain Logic and Storage Reality(数据层在业务语义和存储约束之间建立稳定、可测试、可演化的契约)
Chapter 140: Schema, Migration, Data Evolution, and Application Compatibility
- 140.1 Schema Is a Long-Lived Application Contract(数据库 schema 定义字段、类型、约束、索引、关系和默认值,是应用、查询、迁移、权限和数据质量共同依赖的长期契约)
- 140.2 Migration Changes Both Structure and Runtime Assumptions(一次 migration 可能增加字段、拆表、建索引、修改类型、回填数据或删除旧结构,也会改变正在运行的旧代码和新代码对数据的假设)
- 140.3 Backward-Compatible Migration Protects Rolling Deployments(在多实例、serverless、edge、灰度和回滚环境下,旧版本代码和新版本数据库可能同时存在,因此 migration 需要兼容新增、双写、回填和延迟删除策略)
- 140.4 Data Backfill Is Part of Schema Evolution(新增非空字段、派生字段、索引重建、分区迁移和模型重构通常需要 backfill;这会消耗资源、影响锁和性能,并需要可恢复执行)
- 140.5 Constraints Encode Business Invariants at the Storage Boundary(唯一约束、外键、非空、check、索引和事务规则在数据库边界保护重要业务不变量,并与应用层校验互相补强)
- 140.6 Schema Drift Breaks API, Cache, and UI Assumptions(当数据库 schema、ORM model、API response、client type、缓存数据和 UI 字段假设不一致时,就会出现运行时错误、旧缓存、空字段和展示异常)
- 140.7 Safe Evolution Requires Expand, Migrate, Contract(复杂 schema 演化通常应先扩展结构、让新旧代码兼容运行、迁移数据并验证,再收缩旧字段和旧路径,把破坏性修改拆成可回滚步骤)
Chapter 141: Transaction, Connection Pool, Isolation, and Consistency Guarantees
- 141.1 Transaction Groups Multiple Operations into One Consistency Boundary(事务把多个读写操作组织为一个原子边界,使订单创建、库存扣减、支付记录、权限变更等多步骤业务要么整体成功,要么整体回滚)
- 141.2 ACID Properties Protect Different Failure Dimensions(Atomicity 处理部分失败,Consistency 维护约束不变量,Isolation 控制并发可见性,Durability 保证提交后结果在故障后仍然保留)
- 141.3 Isolation Level Changes What Concurrent Users Can Observe(较低隔离级别提升并发但可能允许脏读、不可重复读、幻读、丢失更新等异常;较高隔离级别减少异常但可能增加阻塞、冲突和重试)
- 141.4 Connection Pool Is a Shared Runtime Resource(数据库连接需要区分无限资源,Web server、serverless function、background job、edge adapter 和 ORM 都可能争用连接池)
- 141.5 Long Transactions Increase Lock, Contention, and Timeout Risk(事务持续时间越长,越可能持有锁、阻塞其他请求、增加死锁概率、占用连接并放大用户等待时间)
- 141.6 Distributed Work Weakens Simple Transaction Assumptions(当一次业务写入跨越数据库、对象存储、队列、第三方支付、邮件服务和缓存时,单一数据库事务覆盖范围收缩到局部资源,外部副作用需要补偿、幂等和最终一致性设计)
- 141.7 Consistency Guarantee Must Match User-Visible Promise(系统不必所有地方都强一致,但必须明确哪些场景需要立即一致,哪些可以最终一致,以及用户界面如何表达处理中、已确认或可能延迟)
Chapter 142: Domain Logic, Service Layer, Repository, and Use Case Boundary
- 142.1 Domain Logic Defines What the System Means(领域逻辑表达订单能否创建、文章能否发布、用户能否邀请成员、库存如何扣减等业务规则,超过简单数据库 CRUD 的范围)
- 142.2 Service Layer Coordinates Use Cases Across Boundaries(service layer 可以组织验证、权限、事务、外部服务、事件、缓存失效和返回结果,把一次用户意图转化为完整业务流程)
- 142.3 Repository Encapsulates Data Access While Exposing Cost Boundaries(说明 repository 如何隔离数据访问细节,并保留查询成本、事务和分页等工程信号)
- 142.4 Use Case Boundary Keeps UI Actions from Becoming Database Scripts(每个用户意图应对应清晰 use case,例如提交订单、发布文章、上传头像、邀请成员,把数据库操作收束到可信用例)
- 142.5 Domain Logic Must Run in a Trusted Boundary(涉及权限、支付、库存、审计、配额、订阅、租户和资源归属的逻辑必须在可信 server 或 backend service 中执行,由服务端可信策略负责判断)
- 142.6 Cross-Cutting Concerns Should Be Explicitly Integrated(日志、审计、限流、事务、cache invalidation、事件发布、错误映射和指标埋点都需要明确进入 use case,在用例边界内集中组织)
- 142.7 Good Domain Boundaries Make Framework Changes Less Dangerous(业务规则清晰存在于 use case / service / domain layer 中时,更换 UI framework、API 风格、ORM 或部署平台更可控)
Chapter 143: Serialization, Data Validation, and Persistence Contract
- 143.1 Persistence Requires Converting Runtime Values into Stable Representations(Date、decimal、enum、JSON、binary、nullable、id、timezone 和 encoding 进入存储前需要稳定表示)
- 143.2 Validation Must Match the Boundary Being Crossed(表单输入、API body、domain object、database row、file metadata、third-party callback 都需要不同层级的验证)
- 143.3 Database Constraints Are the Last Line of Data Integrity(应用层 schema 能改善错误提示和开发体验,但数据库约束仍应保护唯一性、引用完整性、非空、范围、枚举和关键不变量)
- 143.4 Serialization Bugs Become Long-Lived Data Bugs(时区错误、浮点精度、JSON 丢字段、字符串截断、编码错误、enum 改名、nullable 误解和旧版本数据,会长期留在数据库里影响未来功能)
- 143.5 Input Shape, Domain Shape, and Storage Shape Can Differ(说明 form data、domain object 和 row/document 之间的显式映射和验证关系)
- 143.6 Persistence Contract Must Be Compatible with API and Cache Contracts(如果数据库字段、API response、client type、query cache 和静态生成数据不一致,系统会出现类型正确但语义错误的状态)
- 143.7 Stable Data Requires Validation Before and After Persistence(写入前要验证输入和业务规则,写入后也要确认返回值、派生字段、数据库默认值、触发器和缓存更新符合应用预期)
Chapter 144: File Upload, Object Storage, Media Asset, and Large Data Path
- 144.1 File Upload as a Structured System(文件上传涉及浏览器 File 对象、multipart encoding、streaming、大小限制、进度、取消、病毒扫描、对象存储、元数据和权限控制)
- 144.2 Upload Path May Go Through Server or Directly to Object Storage(文件可以先上传到应用服务器再转存,也可以通过预签名 URL 直接上传对象存储;两种路径会改变带宽、权限、审计和失败恢复)
- 144.3 Metadata and Binary Data Have Different Lifecycles(文件二进制内容通常放在对象存储,文件名、大小、类型、hash、owner、权限、处理状态和业务关联放在数据库,两者必须保持一致)
- 144.4 Large Files Need Progress, Resume, Chunking, and Cancellation(大文件上传需要进度反馈、分片上传、断点续传、取消、重试、超时处理和网络变化恢复,否则用户体验会很脆弱)
- 144.5 Media Assets Often Need Post-Processing Pipelines(图片压缩、缩略图、视频转码、音频波形、内容审核、EXIF 清理、格式转换和 CDN 发布适合进入异步后台流程)
- 144.6 Object Storage Permissions Must Match Application Authorization(对象存储的 bucket policy、signed URL、public/private ACL、CDN token 和应用权限必须一致,否则会出现越权下载或公开泄漏)
- 144.7 File Lifecycle Requires Cleanup and Orphan Handling(上传成功但数据库写入失败、用户取消、旧头像替换、资源删除、转码失败都会产生孤儿文件或无效引用,需要清理和审计机制)
Chapter 145: Serverless Database, Edge Data, and Connection Lifecycle Constraints
- 145.1 Serverless Runtime Changes Database Connection Assumptions(serverless function 会快速扩缩、频繁冷启动,并发实例可能远超传统服务器数量,使普通长连接和连接池策略失效)
- 145.2 Connection Pooling Must Match Runtime Lifecycle(Node server、serverless、edge adapter、background worker 对 connection reuse、pool size、cold start 和 timeout 的要求不同)
- 145.3 Edge Runtime Proximity Must Be Compared with Data Distance(说明 edge 执行层靠近用户时仍要评估数据库区域和往返成本)
- 145.4 Edge-Compatible Data Access Often Requires Different Storage Models(edge data access 常依赖 HTTP database、global KV、read replica、cache、queue 或 region-aware routing)
- 145.5 Replication Lag Creates Freshness and Consistency Tradeoffs(读副本、全球复制、边缘缓存和异步同步会引入复制延迟,用户可能看到旧数据或写后读不一致,需要明确 UI 和业务容忍度)
- 145.6 Data Location Is a Deployment and Compliance Boundary(数据存放在哪个 region、是否跨境复制、是否进入 edge cache、是否保留日志,都会影响隐私、合规、延迟和灾难恢复)
- 145.7 Modern Data Architecture Must Design for Runtime Topology(数据库架构需要把 schema、serverless、edge、CDN、region、连接池、复制、缓存和部署拓扑共同纳入设计)
Part 21: Cache Topology, Revalidation, Freshness, and Consistency Failure
Chapter 146: Cache as a Multi-Layer Web System
- 146.1 Cache Is a Distributed Copy System(缓存是在 browser、CDN、server、framework runtime、client query layer 中保存副本并管理新鲜度的系统)
- 146.2 Every Cache Trades Freshness for Latency, Cost, or Availability(缓存的核心收益是降低延迟、减少带宽、保护源站、改善离线能力或降低计算成本,但代价是数据可能过期、失效复杂和一致性难以保证)
- 146.3 Cache Location Determines What It Can Know(browser cache 持有用户上下文,CDN cache 靠近用户并服务公共副本,server cache 能访问业务上下文)
- 146.4 Cache Key Defines the Identity of a Cached Result(缓存键决定哪些请求、用户、语言、权限、设备、版本和参数被视为同一份结果;缓存键错误会导致命中率低、数据串用或隐私泄漏)
- 146.5 Cache Lifetime Defines When a Copy Stops Being Trustworthy(TTL、max-age、stale-while-revalidate、tag invalidation、manual purge 和 mutation event 共同定义副本生命期)
- 146.6 Cache Ownership Determines Who May Invalidate It(不同缓存层由浏览器、CDN、应用服务器、framework runtime、client data layer 或用户设备拥有,失效责任必须明确)
- 146.7 Cache Architecture Must Be Designed Across Layers(缓存架构要同时画出 browser、CDN、server cache、framework cache、query cache 的 key、owner、TTL 和 invalidation path)
Chapter 147: Browser Cache, HTTP Cache, Validation, and Resource Freshness
- 147.1 Browser Cache Reuses Resources Inside the User Agent(浏览器会缓存 HTML、CSS、JavaScript、图片、字体、媒体和部分响应,使同一用户后续访问可以减少网络请求和传输成本)
- 147.2 HTTP Cache Is Controlled by Response Metadata(Cache-Control、ETag、Last-Modified、Vary、Expires、Age 和 status code 共同控制 HTTP cache 行为)
- 147.3 Fresh Response Can Be Used Directly(当响应仍在 freshness lifetime 内时,浏览器可以直接复用本地副本,从而降低延迟和源站负载)
- 147.4 Stale Response Requires Validation or Explicit Stale Policy(当缓存副本过期后,浏览器通常需要通过条件请求验证资源是否变化;如果策略允许,也可以在特定条件下先使用 stale response)
- 147.5 ETag and If-None-Match Enable Conditional Revalidation(ETag 让客户端保存资源版本标识,后续通过
If-None-Match询问服务器资源是否变化;未变化时服务器可以返回 304,减少完整内容传输) - 147.6 Reload, Hard Reload, and History Navigation Use Different Cache Paths(普通刷新、强制刷新、后退前进、BFCache 恢复、service worker 拦截和清缓存刷新,可能触发完全不同的缓存读取与验证行为)
- 147.7 Browser Cache Bugs Often Look Like Deployment Bugs(旧 JS chunk、旧 CSS、HTML 引用过期资源、字体缓存不一致、service worker 缓存旧 shell,都会表现为白屏、样式错乱或功能失效)
Chapter 148: CDN Cache, Edge Cache, Region, and Global Delivery
- 148.1 CDN Cache Moves Copies Closer to Users(CDN 通过在全球边缘节点保存静态资源或可缓存响应,减少用户到源站的距离,提高资源加载速度并降低源站压力)
- 148.2 Edge Cache Is a Geographic and Policy Boundary(edge cache 靠近用户,也可以根据 region、header、cookie、device、language、auth state 或自定义规则决定是否缓存和如何转发)
- 148.3 CDN Cache Works Best for Public, Stable, and Versioned Assets(带内容 hash 的 JavaScript、CSS、图片、字体和公开静态文件非常适合长期缓存;HTML 和个性化响应则需要更谨慎的策略)
- 148.4 Personalization Reduces Shared Cache Safety(当响应依赖 cookie、authorization、locale、tenant、role 或实验分组时,共享缓存必须准确区分缓存键,否则可能把一个用户的数据返回给另一个用户)
- 148.5 Purge and Invalidation Are Deployment Operations(CDN purge、cache tag invalidation、surrogate key、soft purge 和版本化 URL 都属于发布流程设计)
- 148.6 Regional Cache Can Create Temporarily Different Worlds(不同 edge region 的缓存状态可能不一致,用户在不同地区或路由到不同节点时,可能看到不同版本的页面、资源或数据)
- 148.7 Global Delivery Must Balance Speed, Freshness, and Control(CDN 策略需要同时考虑全球延迟、命中率、源站保护、失效速度、调试难度、合规区域和用户个性化)
Chapter 149: Server Framework and Runtime Cache Layers
- 149.1 Server Cache Avoids Repeating Expensive Backend Work(server cache 可以缓存数据库查询、API 调用、模板渲染、权限结果、配置、feature flag 或聚合数据,减少服务器计算和后端依赖压力)
- 149.2 Framework Cache Encodes Rendering and Data Fetching Assumptions(framework cache 会绑定 fetch、route segment、RSC payload、static generation、revalidate tag 和 deployment output)
- 149.3 Static Generation Cache Blurs Build-Time and Runtime(SSG、ISR、on-demand revalidation 等机制把构建产物和运行期更新结合起来,使“静态页面”也可能在运行时被重新生成)
- 149.4 Runtime Cache Must Respect Request Context(server cache 如果忽略 cookie、auth、tenant、locale、role 或 feature flag,就可能把上下文相关结果缓存成全局结果)
- 149.5 Cache Tags and Dependencies Make Invalidation More Precise(通过 cache tag、dependency graph、resource key 或 route segment key,可以让 mutation 后只失效相关缓存)
- 149.6 Server Cache Failure Can Be Silent(服务端缓存错误往往表现为旧数据、权限错乱、部分页面停留旧版本、某些区域数据不一致或只有特定用户看见错误)
- 149.7 Framework Cache Must Be Read as Architecture(框架缓存需要区分免费优化,它决定数据何时读取、结果何时复用、何时重新验证、谁能失效,以及用户看到的内容是否新鲜)
Chapter 150: Client Query Cache, Server State, and UI Freshness
- 150.1 Client Query Cache Stores Remote State Snapshots(client query cache 保存的是远端数据的本地快照,业务事实仍以服务器或数据库为准)
- 150.2 Stale Data Can Preserve UI Continuity When Labeled(说明 stale 数据在后台刷新期间的展示、标记和业务确认边界)
- 150.3 Query Key Is the Client-Side Cache Identity(query key 通常需要包含资源 id、过滤条件、分页、排序、tenant、locale、auth context 等维度,否则会出现数据串用或重复请求)
- 150.4 Background Refetch Separates Responsiveness from Freshness(后台重新获取数据可以让用户先看到已有内容,同时需要处理请求失败、旧数据继续显示、局部刷新和结果乱序)
- 150.5 Optimistic Update Temporarily Moves Authority to the Client(乐观更新让客户端先预测 mutation 成功结果,但必须通过 server echo、refetch、rollback 或 reconciliation 回到服务器事实)
- 150.6 UI Freshness Is a Product Decision(股票、聊天、库存、权限、评论、文章详情、用户资料对新鲜度要求不同;需要区分所有 UI 都需要同样频率刷新)
- 150.7 Client Cache Must Coordinate with Route and Mutation State(client cache 需要跟随 route params、auth context、mutation result、optimistic update、background refetch 和 invalidation scope)
Chapter 151: Revalidation, Invalidation, Purge, and Stale-While-Revalidate
- 151.1 Revalidation Asks Whether a Cached Copy Is Still Valid(revalidation 通过 ETag、Last-Modified、tag、timestamp、background refetch 或 framework signal 确认副本是否还能使用)
- 151.2 Invalidation Declares That a Cached Copy Should No Longer Be Trusted(invalidation 是主动宣布某些缓存结果过期,通常由 mutation、发布、权限变化、后台任务或手工管理触发)
- 151.3 Purge Removes or Marks CDN and Edge Copies for Refresh(purge 常用于 CDN 或 edge cache,强制边缘节点删除或刷新旧响应;它是部署与内容更新流程的重要环节)
- 151.4 Stale-While-Revalidate Trades Immediate Response for Background Freshness(stale-while-revalidate 允许先返回旧响应,同时后台重新验证或刷新,改善响应速度但可能让用户短时间看到旧内容)
- 151.5 Revalidation Strategy Must Match Data Volatility(内容越稳定,缓存时间可以越长;数据越实时、权限越敏感或业务影响越大,revalidation 和 invalidation 就必须更严格)
- 151.6 Mutation Should Trigger the Right Revalidation Scope(一次写入可能需要失效详情、列表、计数、搜索结果、权限、导航菜单、static page 和 CDN cache,范围判断错误会造成旧 UI 或过度刷新)
- 151.7 Revalidation Is a Consistency Protocol Across Cache Layers(browser、CDN、server、framework、client cache 都要协调刷新顺序、失败策略和用户可见状态)
Chapter 152: Cache Key, Vary, Credential, Locale, and Personalization Boundary
- 152.1 Cache Key Decides Who Shares a Response(缓存键决定哪些请求被视为同一响应;如果 cache key 没有包含必要维度,就可能把不该共享的数据共享出去)
- 152.2 Vary Expands Cache Identity with Request Headers(
Vary告诉下游缓存用哪些请求 header 区分响应,例如Accept-Encoding、Accept-Language或自定义 header) - 152.3 Credentials Usually Make Shared Caching Dangerous(带 cookie 或 authorization 的请求通常包含用户上下文,如果被共享缓存错误复用,可能造成隐私泄漏或权限绕过)
- 152.4 Locale and Language Affect Content Identity(同一路径在不同语言、地区、货币、时区和文本方向下可能返回不同内容,因此 locale 必须进入 URL、header、cookie 或 cache key 设计)
- 152.5 Personalization Turns Cache from Global Copy into Segmented Copy(登录状态、会员等级、推荐、实验分组、地理位置、设备类型和权限都会把响应分裂成多个个性化版本)
- 152.6 Cache Fragmentation Reduces Hit Rate(缓存维度越多,命中率越低;为了正确性加入过多维度,也可能让缓存几乎无法复用)
- 152.7 Safe Personalization Requires Separating Public and Private Layers(常见策略是把公开可缓存 shell、静态资源、匿名内容与用户私有数据分离,让共享缓存和私有缓存各自承担合适职责)
Chapter 153: Stale Data, Split Brain UI, and Cache Consistency Failure
- 153.1 Stale Data Becomes a Bug When the UI Pretends It Is Fresh(过期数据可能有问题,但如果界面把它展示成最终事实,用户可能基于旧信息做出错误操作)
- 153.2 Split Brain UI Shows Different Truths in Different Places(同一个资源在详情页、列表页、侧边栏、通知数、搜索结果和缓存副本中显示不同状态时,用户会感觉系统自相矛盾)
- 153.3 Cache Race Happens When Refresh and Mutation Interleave(后台刷新、乐观更新、mutation result、route navigation 和自动 refetch 同时发生时,旧请求可能覆盖新状态)
- 153.4 Permission Changes Make Cached Data Dangerous(用户退出组织、权限降低、订阅过期、session 失效后,如果缓存仍显示旧数据,就可能造成越权可见或误操作)
- 153.5 Deployment Version Skew Breaks Cached Assets and Data Shapes(HTML、JS chunk、API schema、RSC payload、service worker、CDN cache 如果来自不同版本)
- 153.6 Consistency Failure Needs Diagnosis Across All Cache Layers(排查旧数据要检查 query key、server cache、CDN region、HTTP header、framework revalidate、service worker 和 deployment version)
- 153.7 Cache Architecture Is Correct Only When Failure Modes Are Designed(好的缓存系统是能在失效、刷新、回滚、权限变化、网络失败和版本切换时保持安全、可解释和可恢复)
Part 22: Source Transformation, Package Graph, Bundling, and Build Artifacts
Chapter 154: Source to Artifact Transformation Path
- 154.1 Source Code as a Structured System(开发者写下的 TypeScript、JSX、CSS、Markdown、image、font、route file、config file 会经过编译、打包、拆分和部署转换后成为线上系统)
- 154.2 Build Pipeline Converts Developer Intent into Runtime Artifacts(构建流程把源码中的模块、组件、样式、资源、路由、环境变量和依赖关系转换成浏览器、服务器、edge 或静态托管可以执行和加载的产物)
- 154.3 Transformation Changes Both Syntax and Semantics(TypeScript 删除类型、JSX 变成函数调用或编译输出、CSS 被处理和拆分、import 被重写、环境变量被替换,这些转换会改变代码在运行时的形态)
- 154.4 Build Time Captures Decisions That Runtime Must Obey(哪些代码进入 client bundle、哪些留在 server output、哪些资源被 hash、哪些路由静态生成、哪些环境变量被内联,都是构建期决定并影响运行期行为)
- 154.5 Artifact Shape Determines Loading, Caching, and Debugging(构建产物的文件数量、chunk 关系、hash、source map、CSS 拆分、asset 路径和 manifest 会影响浏览器加载、CDN 缓存、错误定位和回滚)
- 154.6 Build Failure Is a System Boundary Failure(构建失败可能来自类型错误、模块解析失败、环境变量缺失、平台 API 不兼容、server/client boundary 混淆、依赖版本冲突或资源处理错误)
- 154.7 Modern Web Build Is Architecture(构建系统需要区分项目脚手架的附属物,它决定代码在哪里运行、如何加载、如何缓存、如何调试、如何发布和如何回滚)
Chapter 155: ESM, CJS, Module Graph, and Package Boundary
- 155.1 Module System Defines How Code Units Depend on Each Other(模块系统决定一个文件如何导入另一个文件、导出哪些能力、何时执行模块顶层代码,以及依赖关系如何被工具分析)
- 155.2 ESM Enables Static Import and Export Analysis(ES modules 使用
import/export形成较稳定的静态依赖结构) - 155.3 CommonJS Uses Runtime-Oriented Require and Exports(CommonJS 通过
require()和module.exports组织模块,长期服务 Node.js 生态) - 155.4 Module Graph Is the Build-Time Shape of the Application(bundler 会从 entry point 出发解析 import / require / dynamic import / CSS import / asset import)
- 155.5 Package Boundary Is Defined by
package.json, Exports, Imports, and Conditions(一个 npm package 的入口、子路径、类型、browser 条件、module 条件、types、sideEffects 等配置) - 155.6 Dual ESM/CJS Packages Create Compatibility and Resolution Complexity(同时发布 ESM 和 CJS 的包需要处理 default export、named export、条件导出、类型定义、测试环境和不同 bundler 的解析差异)
- 155.7 Module Boundary Mistakes Become Runtime or Bundle Bugs(循环依赖、错误 side effect 标记、混用 ESM/CJS、错误 export map、动态 require、server-only 模块进入 client bundle)
Chapter 156: Package Manager, Lockfile, Workspace, and Monorepo Dependency Graph
- 156.1 Package Manager Resolves Dependency Versions into an Installable Graph(npm、pnpm、Yarn 等包管理器把
package.json中的语义版本范围解析成具体依赖图,并决定 node_modules、软链接、store 和安装结构) - 156.2 Lockfile Freezes the Resolved Dependency World(lockfile 记录具体包版本、完整性校验和依赖关系,使 CI、部署、团队协作和回滚可以获得可重复安装结果)
- 156.3 Transitive Dependencies Are Part of the Application Supply Chain(应用同时依赖直接安装的包和大量间接依赖;这些依赖会影响安全、体积、许可证、构建时间和运行时行为)
- 156.4 Workspace Connects Multiple Packages into One Development System(workspace 让多个内部包在同一仓库中协作,适合 design system、shared types、server package、client package 和工具包)
- 156.5 Monorepo Dependency Graph Must Match Build and Deployment Boundaries(monorepo 里的包依赖关系应与实际构建、测试、部署、server/client boundary 和权限边界对齐,否则会出现循环依赖和产物污染)
- 156.6 Dependency Hoisting and Resolution Affect Runtime Reality(不同包管理器的 hoisting、dedupe、peer dependency、alias、override 和 patch 策略,会改变实际加载到的代码版本)
- 156.7 Package Graph Is a Security and Maintenance Boundary(依赖图过深、包长期不维护、供应链攻击、postinstall script、恶意包、版本漂移都会把构建系统变成安全边界)
Chapter 157: TypeScript, JSX, Babel, SWC, and Language Lowering
- 157.1 TypeScript Adds Static Types but Emits JavaScript(TypeScript 在构建时提供类型检查、接口约束和开发体验,但类型通常不会作为运行时检查保留在浏览器或 Node 执行环境中)
- 157.2 Type Erasure Creates a Gap Between Compile-Time and Runtime(TypeScript 类型在输出 JavaScript 中消失,运行期输入、API response、database row 仍需要 schema 或断言保护)
- 157.3 JSX Is Syntax for UI Description(浏览器通过明确边界分析 JSX,它需要被转换成函数调用、runtime instruction、template output 或 framework-specific 编译结果)
- 157.4 Babel and SWC Transform Syntax Across Target Environments(Babel、SWC 等工具可以把新语法、JSX、decorator、class field、optional chaining 等转换为目标环境可执行的 JavaScript)
- 157.5 Lowering Strategy Affects Bundle Size and Semantics(面向旧环境的转译会引入 helper、polyfill、regenerator、class transform 和语义兼容代码,可能增加 bundle 和运行时成本)
- 157.6 Type Checking and Transpilation Are Different Build Responsibilities(有些工具只转译不类型检查,有些构建会把 typecheck 放到独立进程或 CI;混淆二者会导致本地能跑但类型错误进入仓库)
- 157.7 Language Toolchain Must Respect Server and Client Targets(TS/JSX/Babel/SWC 配置要区分 browser、Node、edge、worker、test 和 library target)
Chapter 158: Bundler Architecture, Code Splitting, Tree Shaking, and Chunk Graph
- 158.1 Bundler Starts from Entry Points and Builds a Dependency Graph(bundler 会从 HTML、route entry、client entry、server entry、worker entry 或 library entry 出发)
- 158.2 Code Splitting Turns One Graph into Multiple Loadable Chunks(dynamic import、route boundary、vendor split、CSS split、preload hint 会共同形成 chunk graph)
- 158.3 Tree Shaking Removes Unused Exports When Static Analysis Allows It(tree shaking 依赖 ESM 静态结构、side effect 标记和工具分析;动态访问、CommonJS、顶层副作用和错误配置都会降低效果)
- 158.4 Chunk Graph Determines Runtime Loading Waterfalls(chunk 之间的依赖关系会影响 preload、modulepreload、parallel loading、lazy loading 和用户点击后的额外等待)
- 158.5 Bundler Plugins Are Build-Time Capability Extensions(插件可以处理 CSS、images、MDX、WASM、SVG、env、virtual modules、route manifest 和 framework transform)
- 158.6 Production Build Optimizes Differently from Development Server(开发服务器通常重视快速启动、HMR 和按需转换;生产构建则重视压缩、拆分、hash、tree shaking、兼容目标和可缓存产物。Vite 生产构建默认使用 Rollup)
- 158.7 Bundling Is a Tradeoff Between Fewer Requests, Better Cache, and Less Startup Work(把代码打大可以减少请求但增加首包;拆太细可以提高缓存粒度但增加 waterfall;合理 chunk graph 要围绕真实用户路径设计)
Chapter 159: Client Bundle, Server Bundle, Edge Bundle, and Output Target
- 159.1 Output Target Defines the Runtime Assumptions of a Bundle(client、server、edge、worker、library、static asset 等产物面对不同 API、模块格式、安全边界、文件系统、网络能力和生命周期)
- 159.2 Client Bundle Must Assume a Public and Constrained Environment(client bundle 会被用户下载和检查,需要只包含可公开逻辑,同时受网络、CPU、内存和浏览器兼容约束)
- 159.3 Server Bundle Can Access Trusted Resources but Has Deployment Constraints(server bundle 可以访问 secret、数据库、文件系统和内部服务,但受到 Node/Bun/Deno runtime、serverless、容器、冷启动和资源限制影响)
- 159.4 Edge Bundle Optimizes Latency but Limits Runtime Capabilities(edge bundle 运行在靠近用户的隔离 runtime 中,适合低延迟请求处理和轻量逻辑,但可能限制 Node API、文件系统、二进制依赖、连接方式和执行时间)
- 159.5 Worker Bundle Targets Off-Main-Thread Execution(Web Worker、Service Worker、Worklet、Cloudflare Worker 等都可能需要专门打包入口、全局对象、模块格式和资源访问方式)
- 159.6 Server-Only and Client-Only Boundaries Must Be Enforced at Build Time(构建系统需要防止 server-only 模块进入 client bundle,也要防止 client-only API 在 server bundle 中被直接执行)
- 159.7 Multi-Output Frameworks Make Build Artifacts Part of Architecture(full-stack framework 会同时生成 client bundle、server bundle、edge bundle、RSC/data payload、asset manifest 和 route metadata)
Chapter 160: Asset CSS Font and Static Resource Pipeline
- 160.1 Assets Become Runtime Resources Through the Build Pipeline(图片、SVG、字体、视频、WASM、JSON、CSS、icons 等资源在构建中会被复制、压缩、hash、内联、拆分或转换为 URL 引用)
- 160.2 Hashed Filenames Enable Long-Term Immutable Caching(内容 hash 让静态资源可以安全地设置长期缓存,因为文件内容变化会产生新 URL;这也要求 HTML 或 manifest 正确引用最新资源)
- 160.3 CSS Pipeline Handles More Than Text Concatenation(CSS pipeline 会处理 PostCSS、nesting、modules、minification、critical CSS、extraction、injection 和 source map)
- 160.4 CSS Extraction and Injection Change Rendering Timing(CSS 被提取为外部文件、内联为 critical CSS、通过 JS 注入或按 route 拆分)
- 160.5 Font Pipeline Affects Performance and Visual Stability(font subsetting、preload、font-display、fallback metrics、format、CDN cache 会影响 FOUT、FOIT 和 layout shift)
- 160.6 Image Pipeline Should Encode Size, Format, Density, and Loading Strategy(图片构建应考虑压缩、格式转换、响应式尺寸、DPR、懒加载、占位图、宽高声明和 CDN 变体)
- 160.7 Static Resource Emission Must Align with CDN and Deployment Paths(构建输出的 asset path、base URL、public path、manifest、CDN origin 和 cache header 必须一致)
Chapter 161: Source Map, Debug Output, and Production Diagnostics
- 161.1 Source Map Connects Minified Artifacts Back to Original Source(source map 把压缩、合并、转换后的生产代码映射回原始源码,使错误堆栈、调试器和监控平台能定位真实文件和行号)
- 161.2 Source Maps Are Debugging Tools and Information Disclosure Risks(公开 source map 能帮助排查线上问题,但也可能暴露源码、注释、路径、内部逻辑或 secret-like 字符串,需要按产品风险决定是否公开)
- 161.3 Build Metadata Helps Link Errors to Releases(release id、commit sha、build time、artifact manifest、source map upload 和 deployment target 能把线上错误连回具体版本)
- 161.4 Minification and Mangling Change Stack Trace Readability(压缩和变量混淆能减少体积,但会让错误堆栈和性能 profile 难以直接阅读,需要 source map 和错误上报系统恢复上下文)
- 161.5 Production Diagnostics Must Include Both Client and Server Artifacts(现代 full-stack 构建会同时产生 client bundle、server bundle、edge bundle 和静态资源,诊断时必须知道错误发生在哪个产物中)
- 161.6 Debug Output Needs Production Exposure Rules(说明 source map、manifest、stats 和调试文件的发布、缓存和泄漏边界)
- 161.7 Build Observability Completes the Source-to-Artifact Path(build observability 需要保存 bundle stats、chunk graph、source map status、artifact hash、deploy log 和 runtime error link)
Part 23: Server Runtime, Edge Runtime, Serverless, and Deployment Boundaries
Chapter 162: JavaScript Server Runtime Node.js, Bun, Deno, and Host Capability
- 162.1 Server Runtime Runs JavaScript Outside the Browser(JavaScript server runtime 让 JavaScript 在浏览器之外处理 HTTP 请求、访问文件系统、连接数据库、读取环境变量、调用内部服务和生成响应)
- 162.2 Runtime Capability Defines What Code Can Do(runtime capability 包括 file system、TCP、crypto、stream、timer、process、env、native addon、Web API 和 resource limit)
- 162.3 Same JavaScript Language Runs Under Different Host Capabilities(说明 browser、Node、Bun、Deno、edge 和 worker 中的 host capability 差异)
- 162.4 Server Runtime Owns Trusted Execution and Secret Access(server runtime 通常可以访问 database URL、API secret、private token、session secret 和内部服务)
- 162.5 Long-Lived Server Process Changes State Assumptions(传统 server process 可以长期保留内存缓存、连接池、初始化对象和后台任务,但也要处理内存泄漏、热更新、进程崩溃和滚动部署)
- 162.6 Runtime Selection Affects Framework Behavior(同一框架在 Node、edge、serverless、static hosting 下的 routing、streaming、cache、database access 和 cold start 不同)
- 162.7 Server Runtime Is a Boundary Between Web Semantics and Operating Environment(server runtime 把 HTTP request/response 语义连接到底层操作系统、网络、文件、进程、数据库和部署平台)
Chapter 163: Request Handler, Middleware Chain, Response Stream, and Runtime Context
- 163.1 Request Handler Turns HTTP Input into Application Behavior(request handler 接收 method、URL、headers、body、cookies、connection、runtime context)
- 163.2 Middleware Chain Modifies the Request Path Before the Final Handler(middleware 可以在最终 handler 之前做认证、日志、限流、locale、tenant、A/B test、CORS、body parsing、缓存判断和重定向)
- 163.3 Middleware Order Is a Control-Flow Contract(middleware 的顺序决定哪些逻辑先执行、谁能短路请求、谁能读取 body、谁能修改 headers、谁负责错误处理;顺序错误会导致权限绕过或响应异常)
- 163.4 Runtime Context Carries Platform-Specific Capability(context 可能提供 env、request id、region、waitUntil、cache API、platform binding、logger 和 execution deadline)
- 163.5 Response Stream Allows Progressive Output and Backpressure(响应可能是一次性字符串或 JSON;stream 可以逐步写出 HTML、SSE、文件、日志、AI 输出或大数据响应,同时需要处理 backpressure 和连接关闭)
- 163.6 Headers Must Be Finalized Before Body Becomes Irreversible(一旦 response body 开始发送,status 和部分 headers 可能无法再修改)
- 163.7 Request Handling Is a Pipeline(完整请求路径包括平台入口、middleware、路由、handler、数据访问、stream、错误边界、日志、metric 和响应关闭,需要按整条 pipeline 分析)
Chapter 164: Serverless Lifecycle and Resource Limits
- 164.1 Serverless Function Is Event-Driven and Ephemeral(serverless function 通常由请求或事件触发,平台按需创建执行环境,函数实例可能被复用,也可能随时销毁)
- 164.2 Cold Start Adds Initialization to the Request Path(冷启动时,平台需要准备运行时、加载代码、初始化依赖和建立上下文,这些工作会进入用户请求延迟;研究也反复指出冷启动是 FaaS 的主要性能挑战之一)
- 164.3 Warm State Reuse Requires Request-State Isolation(说明 serverless warm state 复用和请求专属状态隔离之间的边界)
- 164.4 Resource Limits Shape Function Architecture(serverless function 往往有执行时间、内存、并发、body size、文件系统、连接数和后台任务限制,这些限制会影响上传、streaming、长任务和数据库访问)
- 164.5 Stateless Design Still Needs External State Coordination(函数本身应尽量无状态,但应用状态必须进入数据库、对象存储、队列、缓存、session store 或外部服务,这会改变数据路径和故障模型)
- 164.6 Dependency Loading and Bundle Size Affect Cold Start(大型依赖、ORM 初始化、动态 require、重型 SDK、图像处理库和过大的 server bundle 会增加冷启动和内存占用)
- 164.7 Serverless Isolation and Reuse Create Security Tradeoffs(函数实例复用提高效率,同时要求清理跨请求数据残留;研究中也提出过针对 FaaS 实例复用隔离问题的系统方案)
Chapter 165: Edge Runtime, Worker Model, Region, Latency, and Isolation Boundary
- 165.1 Edge Runtime Moves Execution Closer to Users(edge runtime 把部分请求处理放到靠近用户的区域或边缘节点,适合重定向、缓存判断、地理路由、轻量认证、A/B test 和低延迟响应)
- 165.2 Worker Model Often Uses Lightweight Isolation Instead of Full Servers(许多 edge runtime 使用 isolate / worker 模型,与传统长生命周期服务器进程形成不同约束,这会影响全局状态、启动速度、API 支持和资源限制)
- 165.3 Region Selection Changes Latency and Data Access(edge 靠近用户需要结合上下文判断靠近数据库;如果数据仍在单一区域,edge 到数据库的往返可能抵消用户到 edge 的延迟收益)
- 165.4 Edge Runtime Has a Smaller Host Capability Surface(edge 环境通常限制文件系统、原生模块、长 TCP 连接、某些 Node API、进程操作和长时间后台任务,因此代码必须匹配平台能力)
- 165.5 Edge Cache and Edge Compute Must Be Designed Together(边缘计算经常与 CDN cache、KV、durable object、regional cache、static asset、request rewrite 一起工作)
- 165.6 Isolation Boundary Protects Multi-Tenant Edge Execution(edge 平台需要在同一基础设施上运行许多租户代码,因此隔离、CPU 限制、内存限制、subrequest 限制和安全审计非常重要)
- 165.7 Edge Is Best Under Clear Data and Capability Constraints(适合 edge 的逻辑通常是轻量、低延迟、少依赖、少私密状态、可缓存、可降级;重事务、复杂数据库连接和大文件处理可能适合放到 edge)
Chapter 166: Environment Variable, Secret, Runtime Config, and Deployment Scope
- 166.1 Configuration Has Different Scopes at Build Time and Runtime(构建时配置可能被内联到产物,运行时配置可以随部署环境变化;混淆二者会导致 secret 泄漏或线上行为无法修改)
- 166.2 Public Environment Variables Are Public Artifacts(说明进入 client bundle、HTML、source map、static asset 或 response 的变量都属于公开暴露面)
- 166.3 Secret Scope Must Match Runtime Trust Level(browser、edge、serverless、origin server、CI、preview environment 应拥有不同 secret 集和访问权限)
- 166.4 Runtime Config Enables Deployment-Time Behavior Control(runtime config 可以控制 feature flag、endpoint、region、log level、experiment、rate limit 和第三方服务开关)
- 166.5 Preview and Production Environments Need Separate Trust Boundaries(preview deployment 服务临时代码和测试数据,需要隔离生产数据库、生产 secret 和真实用户权限)
- 166.6 Secret Rotation Must Be Compatible with Running Instances(secret 轮换时,旧实例、缓存连接、session 签名、webhook 验证、background job 和 edge region 可能仍使用旧值)
- 166.7 Configuration Bugs Become Environment-Specific Failures(本地正常、预览失败、生产失败、某个 region 失败,常常来自配置、secret、环境变量、权限和部署范围不一致)
Chapter 167: Deployment Artifact, Preview Deployment, Rollback, and Release Boundary
- 167.1 Deployment Artifact Is the Unit That Actually Runs(真正上线的是 HTML、bundle、server output、container image、edge worker、manifest、migration 和 config 的组合)
- 167.2 Preview Deployment Turns Pull Requests into Executable Environments(preview deployment 让每次变更都有独立可访问环境,便于测试 UI、路由、API、缓存、metadata、auth 和构建产物)
- 167.3 Release Boundary Defines What Changes Together(release boundary 决定代码、schema、asset、config、cache rule、feature flag 和 background job 哪些要同步发布)
- 167.4 Rollback Must Consider Assets, Schema, Cache, and Runtime State(回滚同时切回旧代码,还要考虑数据库迁移是否可逆、CDN 是否缓存新资源、客户端是否加载了新 bundle、service worker 是否持有旧逻辑)
- 167.5 Version Skew Is Normal in Web Deployment(用户浏览器、CDN、edge、serverless 实例、server 节点、数据库 schema 和静态资源可能同时处于不同版本;系统必须能容忍短期版本错位)
- 167.6 Deployment Pipeline Must Contain Verification Gates(pipeline 需要包含 build、typecheck、test、preview smoke、migration check、bundle check、security scan 和 rollback check)
- 167.7 Release Engineering Is Web Architecture in Motion(部署流程决定新系统如何替换旧系统、错误如何扩散、回滚是否可行、用户是否中断,因此它是架构本身)
Chapter 168: Streaming Response Across Node, Edge, Serverless, CDN, and Browser
- 168.1 Streaming Depends on Every Layer in the Response Path(应用代码写出 stream 需要结合上下文判断用户会看到渐进响应)
- 168.2 Node Streams and Web Streams Use Different but Related Models(Node.js 长期使用 Node stream 处理文件、HTTP 和数据流)
- 168.3 Serverless Platforms May Restrict Long-Lived Streams(部分 serverless 平台对执行时间、连接保持、buffering、响应大小和后台任务有限制,长 streaming response 需要验证真实平台行为)
- 168.4 Edge Runtime Can Improve First Byte but May Limit Stream Workload(edge 靠近用户可以更快开始响应,但如果 stream 需要持续访问远端数据库、AI 服务或大对象存储,延迟和资源限制仍可能成为瓶颈)
- 168.5 CDN and Proxy Buffering Can Destroy Incremental Delivery(CDN、反向代理、压缩层或安全网关可能缓冲响应,导致用户一次性收到内容,削弱逐步看到 HTML、SSE 或数据块的效果)
- 168.6 Streaming Error Handling Must Be Planned Before Bytes Are Sent(一旦 body 开始发送,status、部分 header 和 redirect 可能已经不可更改;错误只能通过后续 chunk、边界 fallback 或连接关闭表达)
- 168.7 Streaming Is a Cross-Runtime Contract(streaming 是否有效取决于框架、runtime、部署平台、CDN、浏览器和用户网络共同支持,必须用端到端观测验证)
Chapter 169: Runtime Failure, Timeout, Retry, Backpressure, and Graceful Degradation
- 169.1 Runtime Failure Can Happen Before Application Code Runs(冷启动失败、依赖加载失败、平台限流、region 故障、DNS/TLS 问题、环境变量缺失,都可能在业务 handler 执行前让请求失败)
- 169.2 Timeout Is an Architecture Boundary(不同 runtime 对请求处理、后台任务、stream、数据库连接、上传下载有不同超时限制;超过限制时,用户看到的是系统边界失败)
- 169.3 Retry Can Recover or Amplify Failure(客户端、CDN、队列、serverless 平台、数据库 driver 和第三方 SDK 都可能重试;没有幂等性和限流保护时,重试会放大负载和重复写入)
- 169.4 Backpressure Protects the System from Unbounded Work(当下游变慢、客户端读取慢、数据库压力高或 stream 消费滞后时,系统必须通过 backpressure、限流、排队或降级保护内存和连接)
- 169.5 Graceful Degradation Preserves Core User Value During Partial Failure(当推荐服务、图片处理、分析、实时连接、非关键数据源或边缘节点失败时,系统应尽量保留核心页面和核心操作可用)
- 169.6 Observability Must Preserve Runtime Context(日志、trace、metric、error report 要带上 route、user/session scope、tenant、region、release、cache state 和 request id)
- 169.7 Reliable Web Runtime Design Assumes Partial Failure(现代 Web 运行在浏览器、CDN、edge、serverless、server、database 和第三方服务之间,局部失败是常态;架构目标是限制影响并可恢复)
Part 24: Testing, Debugging, Observability, and Performance Verification
Chapter 170: Testing as Evidence Across Web System Boundaries
- 170.1 Testing Is Evidence(测试的目标是为系统行为提供证据:某个输入穿过 browser、UI runtime、API、server、database、cache、deployment boundary 后)
- 170.2 Different Tests Observe Different Boundaries(unit test 观察局部逻辑,component test 观察 UI 单元,integration test 观察模块协作,E2E test 观察真实用户路径)
- 170.3 Web Tests Must Include Browser Reality(真实浏览器测试要覆盖 DOM、CSS、navigation、focus、storage、network、accessibility、hydration 和 rendering timing)
- 170.4 Test Scope Should Match Failure Impact(小函数错误适合 unit test,组件交互适合 component test,API shape 适合 contract test)
- 170.5 Test Data Is Part of the System Model(测试数据必须表达用户、权限、租户、资源归属、缓存状态、数据库状态和边界条件,才能覆盖真实系统路径)
- 170.6 Reliable Tests Need Deterministic Boundaries(时间、随机数、网络、动画、第三方服务、并发、缓存和环境变量都会让测试不稳定,需要 mock、fixture、clock control、test database 和隔离环境)
- 170.7 Good Testing Strategy Maps to Architecture Boundaries(测试策略应对应 unit、integration、API、component、E2E、visual、a11y、performance 和 contract boundary)
Chapter 171: Unit Test, Component Test, Integration Test, and E2E Test
- 171.1 Unit Test Protects Local Logic and Pure Decisions(unit test 适合保护 parser、formatter、validator、policy function、state reducer、cache key builder 等局部逻辑)
- 171.2 Component Test Protects UI Responsibility Boundaries(component test 验证组件在不同 props、state、event、loading、error、disabled、accessibility 状态下的行为)
- 171.3 Integration Test Protects Collaboration Between Modules(integration test 验证 route、loader/action、database adapter、cache layer、auth guard、service function 的协作)
- 171.4 E2E Test Protects User-Critical Paths(E2E test 从用户角度穿过浏览器、路由、UI、网络、服务端、数据库和缓存,适合验证注册、登录、支付、提交、搜索、上传等关键流程)
- 171.5 E2E Test Should Be Valuable(E2E test 成本较高、运行较慢、调试复杂,不适合覆盖所有分支;应优先覆盖业务关键路径、跨边界风险和过去真实出错路径)
- 171.6 Test Pyramid Is a Cost Model(测试金字塔提醒不同测试成本不同,但 Web 应用需要根据 browser complexity、framework boundary、API risk 和用户路径重新平衡)
- 171.7 Flaky Tests Usually Reveal Uncontrolled Boundaries(测试不稳定常来自异步等待、动画、网络、时间、缓存、并发、数据库状态、第三方依赖或环境差异,需要先排查未受控边界)
Chapter 172: Contract Test, API Test, Schema Test, and Compatibility Test
- 172.1 Contract Test Protects Independently Deployed Boundaries(当客户端、服务器、BFF、第三方 API 或移动端独立部署时,contract test 用来证明双方仍然遵守输入、输出、错误和版本约定)
- 172.2 API Test Verifies Protocol-Level Behavior(API test 要检查 method、status、headers、body schema、auth、CORS、rate limit、idempotency 和 error shape)
- 172.3 Schema Test Turns Type Claims into Runtime Evidence(JSON Schema、OpenAPI、GraphQL schema、Zod / Valibot 等 schema 需要在测试中验证真实输入输出,防止文档和实现漂移)
- 172.4 Compatibility Test Protects Older Clients and Cached Worlds(旧客户端、旧 service worker、旧 CDN cache、旧 HTML 引用新 API、新客户端遇到旧 server,都可能出现版本错位,需要兼容性测试覆盖)
- 172.5 Consumer-Driven Contracts Capture Real Client Expectations(consumer-driven contract 让客户端声明自己依赖哪些字段、错误和行为,服务端变更时可以验证是否破坏真实消费方)
- 172.6 Failure Cases Are Part of the Contract(contract 需要覆盖 invalid input、missing auth、permission denied、conflict、timeout、duplicate request 和 stale version)
- 172.7 Contract Testing Makes API Evolution Safer(稳定接口是靠可验证的兼容策略、废弃流程、版本迁移和自动化测试防止破坏性变更)
Chapter 173: Visual Accessibility and Cross-Browser Test Matrix
- 173.1 Visual Regression Protects User-Visible Output(visual regression test 通过截图、像素差异、DOM snapshot 或视觉检查发现布局错乱、样式回退、字体变化、主题破坏和组件重叠)
- 173.2 Visual Tests Need Stable Rendering Conditions(字体、viewport、DPR、动画、时间、随机内容、网络资源和操作系统渲染差异都会影响截图稳定性,需要固定环境和容忍阈值)
- 173.3 Accessibility Test Protects Semantic and Interaction Paths(a11y test 要覆盖 role/name、keyboard path、focus order、aria state、form error、landmark 和 screen reader signal)
- 173.4 Automated Accessibility Tests Need Human Scenario Coverage(说明自动化规则检查和读屏、键盘、复杂交互场景验证的分工)
- 173.5 Cross-Browser Test Protects Platform Assumptions(Chrome、Safari、Firefox、移动浏览器、WebView 对 CSS、Web API、media、storage、privacy、font、input 行为可能不同)
- 173.6 Device Matrix Should Follow User and Capability Risk(测试设备矩阵应根据用户占比、浏览器差异、性能等级、输入方式、屏幕尺寸、网络环境和关键 API 支持来选择)
- 173.7 User-Visible Testing Must Include Failure and Edge States(E2E/visual test 需要覆盖 loading、empty、error、offline、slow network、permission denied、expired session 和 recovery)
Chapter 174: Browser DevTools, Network Panel, Performance Panel, and Memory Panel
- 174.1 DevTools Turns Browser Internals into Observable Evidence(DevTools 能把框架抽象还原为真实浏览器行为,包括请求、DOM、style、layout、script、paint、cache、memory 和 console error)
- 174.2 Network Panel Shows Request Waterfall and Protocol Semantics(Network panel 用 waterfall、priority、cache、protocol、headers、payload、timing 还原请求路径)
- 174.3 Performance Panel Shows Main Thread and Rendering Cost(Performance panel 展示 long task、script、style/layout、paint、composite、frame、input 和 GC 成本)
- 174.4 Memory Panel Reveals Retention and Leak Patterns(Memory panel 通过 heap snapshot、allocation timeline、detached nodes 和 retainers 找到泄漏来源)
- 174.5 Elements and Computed Styles Reveal DOM and CSS Reality(Elements、Computed、Layout、Accessibility 面板帮助确认真实 DOM 结构、样式来源、box model、层叠结果和可访问树)
- 174.6 Coverage and Source Maps Connect Production Artifacts Back to Source(Coverage 能发现未使用代码,source map 能把 minified stack trace 映射回源码,两者都帮助分析构建产物对运行时的影响)
- 174.7 DevTools Should Be Used to Validate Architecture Assumptions(资源是否预加载、缓存是否命中、hydration 是否阻塞、layout 是否抖动、fetch 是否瀑布、JS 是否过大,都应通过 DevTools 证据验证)
Chapter 175: Logs, Metrics, Traces, Error Tracking, and Distributed Request Evidence
- 175.1 Logs Capture Discrete Events and Context(日志记录具体事件、错误、请求上下文、用户或租户标识、部署版本和业务状态,是排查单次故障的基础证据)
- 175.2 Metrics Capture Aggregated System Behavior(指标把延迟、错误率、吞吐、缓存命中、队列长度、CPU、内存、数据库连接、Core Web Vitals 等变成可聚合趋势,用于发现整体退化)
- 175.3 Traces Connect Work Across Services and Boundaries(分布式 trace 通过 trace id / span id 把浏览器请求、edge、server、database、cache、第三方服务和后台任务连接成一条因果路径)
- 175.4 Error Tracking Captures Runtime Failures with Release Context(error tracking 需要收集 stack、source map、release id、route、user context、browser、region 和 breadcrumb)
- 175.5 Correlation IDs Turn Separate Signals into One Incident Story(没有 request id、trace id、session id 或 correlation id,浏览器错误、服务端日志、数据库慢查询和 CDN 事件很难拼成同一个故障故事)
- 175.6 Observability Must Respect Privacy and Security Boundaries(日志和 trace 需要对 token、cookie、个人数据、支付信息、表单敏感字段和内部 secret 做脱敏、过滤和访问控制)
- 175.7 Logs, Metrics, and Traces Are Complementary Evidence(日志解释发生了什么,指标显示规模和趋势,trace 展示跨边界路径;三者结合才能支持异常检测和根因分析)
Chapter 176: Core Web Vitals, Real User Monitoring, and User-Visible Performance
- 176.1 Performance Must Be Judged by User-Visible Outcomes(Web 性能是看用户何时看到主要内容、何时能交互、页面是否稳定、操作是否及时反馈)
- 176.2 Core Web Vitals Capture Loading, Responsiveness, and Visual Stability(Core Web Vitals 关注 LCP、INP、CLS 等用户体验维度:加载主要内容、交互响应性和视觉稳定性)
- 176.3 Lab Data and Field Data Answer Different Questions(Lighthouse、WebPageTest 等 lab 测试适合可重复诊断,RUM / field data 反映真实用户设备、网络、浏览器和地理分布下的体验)
- 176.4 RUM Connects Performance to Real Routes and User Segments(真实用户监控可以按 route、device、network、region、browser、auth state、experiment、release 分析性能)
- 176.5 Performance Regression Should Be Treated as a Release Failure(如果新版本显著增加 LCP、INP、CLS、JS long task、bundle、server latency 或 cache miss,应像功能回归一样阻止或回滚发布)
- 176.6 Performance Budgets Make Quality Enforceable(budget 要约束 JS/CSS/font/image size、LCP、INP、CLS、TTFB、long task、route transition 和 hydration cost)
- 176.7 User-Visible Performance Is a Full-Stack Property(LCP 可能受 server、CDN、HTML、CSS、image、font 影响)
Chapter 177: Debugging Full-Stack Failures from Browser Symptom to Server Cause
- 177.1 Start from the User-Visible Symptom(调试应从用户看到的白屏、卡顿、旧数据、提交失败、登录跳转、样式错乱、权限错误、上传失败等症状开始,再沿系统边界定位责任层)
- 177.2 Reconstruct the Path the User Action Took(故障排查先还原用户从 URL、click/form、request、server handler、data access、cache 到 UI update 的完整路径)
- 177.3 Separate Client Failure, Network Failure, Server Failure, and Cache Failure(白屏、超时、旧数据、权限错误、hydration mismatch、mutation rollback 要分别定位到不同边界)
- 177.4 Use Browser Evidence Before Server Assumptions(先看 console、Network、Performance、DOM、storage、service worker、cache 和用户环境,再判断服务端责任)
- 177.5 Use Server Evidence to Validate Backend and Data Path(用 logs、trace、metrics、database query、cache hit/miss、queue status 和 release id 验证后端路径)
- 177.6 Version and Environment Differences Often Explain “Only Some Users” Bugs(只有部分用户遇到问题,往往与浏览器版本、地区、CDN 节点、A/B 实验、权限、缓存版本、设备性能或部署灰度有关)
- 177.7 Debugging Completes the Architecture Feedback Loop(调试是把真实故障反馈到架构中,修正边界设计、测试覆盖、日志字段、缓存策略、错误恢复和性能预算)
Part 25: Offline, Embedded Web, Extensions, and Specialized Execution Environments
Chapter 178: Offline-First Architecture and Local-Remote State Coordination
- 178.1 Offline-First Starts by Treating Network as Optional(offline-first 是假设网络随时可能不可用、变慢、切换或失败,因此核心读取、写入、恢复和同步路径必须能在不稳定网络下工作)
- 178.2 Local State Becomes a Temporary Source of Truth(离线时,IndexedDB、Cache Storage、local state、draft queue、operation log 可能临时成为用户可见的事实来源)
- 178.3 Offline Read Path Requires Cached Data and Meaningful Fallback(离线读取应根据已有缓存、旧数据、占位内容、只读模式或离线提示提供可分析的用户体验)
- 178.4 Offline Write Path Requires Queues, Idempotency, and Conflict Strategy(离线提交通常需要本地队列、幂等键、重试策略、冲突检测、同步状态和失败恢复来处理网络恢复后的不确定顺序)
- 178.5 Sync Reconciles Local Intent with Remote Reality(重新联网后,系统需要把本地操作、服务器最新状态、权限变化、资源删除和其他用户修改进行协调,通过合并、冲突提示或重试保持一致性)
- 178.6 Offline UX Must Communicate Confidence and Risk(用户需要知道当前看到的是已同步数据、旧缓存、草稿、排队操作、同步失败还是只读副本,否则离线能力会破坏信任)
- 178.7 Offline-First Is a Consistency Architecture(离线优先的核心是在本地可用性、远端一致性、冲突恢复和用户信任之间设计清晰协议)
Chapter 179: PWA Installability, Manifest, Service Worker Update, and App Shell
- 179.1 PWA Moves a Website Toward an Installable App Experience(PWA 让 Web 应用通过 manifest、service worker、HTTPS、图标、启动 URL、display mode 等机制获得更接近安装式应用的入口和体验)
- 179.2 Web App Manifest Describes App Identity and Launch Behavior(manifest 描述 name、short_name、icons、start_url、scope、display、theme color 等信息)
- 179.3 Service Worker Provides Programmable Offline and Update Control(service worker 可以拦截请求、缓存 app shell、处理离线 fallback 和后台事件,使 PWA 能在弱网或离线场景下保持部分可用)
- 179.4 App Shell Separates Stable Frame from Dynamic Content(app shell 模型把导航框架、基础资源和核心 UI 作为可缓存外壳,把业务数据作为运行期加载内容,从而改善启动速度和离线体验)
- 179.5 Service Worker Update Is a Versioning Problem(service worker 更新涉及 install/activate、clients.claim、skipWaiting、old cache、new shell、rollback 和用户会话)
- 179.6 Installability Creates New Security and Trust Expectations(安装式 Web 应用会出现在系统启动器、桌面或主屏幕中,用户会期待稳定身份、清晰 origin、权限透明、可卸载和一致导航)
- 179.7 PWA Architecture Must Include Rollback and Cache Cleanup(PWA 一旦缓存 app shell、静态资源和 service worker 逻辑,发布回滚、破坏性更新和错误资源清理就必须成为部署设计的一部分)
Chapter 180: Browser Extension Execution Model and Permission Boundary
- 180.1 Browser Extension Runs Beside Web Pages(extension 可以通过 content script、background worker、popup、declarativeNetRequest 等能力影响页面环境)
- 180.2 Extension Permissions Define Elevated Capability(host permission、tabs、storage、cookies、webRequest、native messaging 会扩展普通网页以外的能力范围)
- 180.3 Content Scripts Bridge Extension and Page Contexts(content script 可以读取或修改网页 DOM,并通过 message passing 与扩展后台通信;它既接近页面,又需要分层对应于页面自己的 JavaScript)
- 180.4 Background Scripts Own Long-Lived or Event-Driven Extension Logic(扩展后台逻辑负责跨页面状态、监听浏览器事件、处理消息、管理权限和调用高权限 API,生命周期和普通网页不同)
- 180.5 Extension Messaging Is a Privilege Transfer Boundary(网页、content script、background、native messaging 之间的消息如果缺少校验,可能让低权限上下文间接利用扩展的高权限能力)
- 180.6 Extensions Can Alter the Web Application Environment(广告拦截、密码管理器、脚本管理器、翻译插件、企业扩展和恶意扩展都可能修改 DOM、拦截请求、注入脚本或改变用户看到的页面)
- 180.7 Extension Architecture Must Treat Permissions as Product Liability(扩展权限越强,审核、最小权限、数据最小化、用户提示、撤销路径和安全测试越重要)
Chapter 181: WebView, Hybrid Container, Mini-App, and Embedded Web Runtime
- 181.1 WebView Embeds Web Runtime into a Native Application(WebView 把 HTML、CSS、JavaScript 运行在原生应用内部,使 Web 技术可以用于移动端、桌面端、超级 App 或企业容器中的界面)
- 181.2 Hybrid Apps Combine Web UI with Native Capability Bridges(Cordova 等混合方案通过 WebView 承载 Web 代码,并通过 native plugin 或 bridge 访问摄像头、文件、传感器、推送、支付等设备能力)
- 181.3 Native Bridge Is a High-Risk Capability Boundary(native bridge 需要校验 message origin、schema、permission、operation allowlist、callback lifecycle 和日志审计)
- 181.4 Embedded Web Has a Smaller Host Capability Surface(说明 WebView 在地址栏、安全提示、更新、Cookie 和调试能力上的宿主边界)
- 181.5 Mini-App Containers Add Platform-Specific Lifecycle and API Rules(小程序、超级 App 容器、企业内嵌平台通常有自己的路由、生命周期、权限、包体、审核、缓存和 API 限制,Web 代码需要适配容器契约)
- 181.6 Embedded Runtime Changes Auth, Storage, and Navigation Assumptions(WebView 中的 cookie、token、SSO、返回按钮、深链接、文件选择、支付回调和跨页面状态,都可能被原生容器接管或改变)
- 181.7 Embedded Web Architecture Must Define Host-App Responsibility(必须明确哪些能力由网页负责、哪些由原生宿主负责、哪些状态共享、哪些错误回传、哪些权限可撤销,以及如何调试和升级)
Chapter 182: Electron, Tauri, Desktop Web Runtime, and Native Boundary
- 182.1 Desktop Web Runtime Packages Web UI as a Desktop Application(Electron、Tauri 等桌面 Web runtime 把 Web UI、JavaScript 逻辑和原生系统能力打包成桌面应用)
- 182.2 Renderer and Main Process Boundaries Protect Native Capability(桌面 Web runtime 通常区分渲染进程和主进程 / 后端进程,Web UI 应通过受控 IPC 调用系统能力)
- 182.3 Native API Access Expands Both Power and Attack Surface(文件系统、shell、剪贴板、进程、自动更新、数据库、通知、硬件和本地网络访问让桌面 Web 应用更强,也让 XSS 或依赖漏洞后果更严重)
- 182.4 Desktop Packaging Creates Update, Signing, and Distribution Boundaries(桌面应用需要处理代码签名、自动更新、安装包、权限提示、崩溃报告、平台差异和离线运行,这些需要区分普通网站部署问题)
- 182.5 Local Persistence Becomes More Durable and More Dangerous(桌面应用可以长期保存本地数据库、配置、token、缓存和文件,因此需要加密、备份、迁移、清理和用户数据导出策略)
- 182.6 Desktop Web Performance Keeps Browser Runtime Constraints(说明桌面资源变化后 DOM、JS、layout、GC、GPU 和渲染进程约束仍需纳入判断)
- 182.7 Desktop Web Runtime Is a Native Boundary Wrapped Around Web Architecture(桌面 Web 应用是 Web runtime、原生权限、进程隔离、本地持久化和发布体系的组合架构)
Chapter 183: Realtime Collaboration, Presence, CRDT, OT, and Conflict Resolution
- 183.1 Realtime Collaboration Is Shared State Under Concurrent Editing(多人协作是多个用户、多个设备、多个网络状态同时修改同一份共享状态,并期望最终结果可分析)
- 183.2 Presence Is Ephemeral State, Document Data Is Durable State(在线状态、光标、选择区、正在输入属于临时协作状态;文档内容、评论、权限、版本历史属于更持久的数据状态,两者生命周期不同)
- 183.3 Operational Transformation and CRDT Address Concurrent Edit Merging(OT 和 CRDT 都试图处理并发编辑和冲突合并;OT 在协同编辑领域长期使用,CRDT 强调副本可独立更新并最终收敛,两类方案有不同复杂度和权衡)
- 183.4 Local-First Editing Requires Optimistic Local Application(为了保持低延迟体验,协作系统通常先在本地应用操作,再通过网络同步给其他用户和服务器;这要求操作可回放、可合并、可撤销或可修正)
- 183.5 Sync Protocol Must Handle Ordering, Duplication, and Offline Gaps(实时协作需要处理消息乱序、重复、丢失、重连、离线操作、版本向量、快照压缩和历史裁剪)
- 183.6 Conflict Resolution Is a Product Experience(即使底层算法能合并操作,用户仍需要分析谁改了什么、为什么内容变化、如何撤销、如何恢复版本和如何处理语义冲突)
- 183.7 Collaboration Architecture Crosses UI, Transport, Storage, and Consistency Boundaries(协作系统同时涉及编辑器 UI、WebSocket/WebRTC、server ordering、local storage、database、权限、presence 和历史记录)
Chapter 184: Product-Specific Web Architecture Patterns and System Constraints
- 184.1 Product Type Changes Which Web Boundaries Matter Most(内容站、SaaS、dashboard、电商、编辑器、PWA、媒体应用关注的 SEO、cache、auth、offline、realtime 权重不同)
- 184.2 Content and Documentation Sites Optimize Public Discovery and Static Delivery(文档站和内容站通常重视稳定 URL、metadata、sitemap、SSG、CDN cache、搜索发现、可访问性和低维护部署)
- 184.3 Dashboards Optimize Authenticated Data Freshness and Interaction Density(SaaS dashboard 通常重视登录态、权限、server state、图表、过滤、刷新、实时更新、错误恢复和长会话性能)
- 184.4 E-Commerce Optimizes Conversion, Consistency, and Transaction Safety(电商系统要平衡 SEO、商品缓存、库存新鲜度、购物车、支付、订单幂等、推荐、图片性能和促销规则)
- 184.5 Editors and Creative Tools Optimize Local State, Performance, and Recovery(富文本编辑器、设计工具、音视频工具和代码编辑器更依赖本地状态、撤销栈、自动保存、Worker、Canvas/WebGL/WebGPU、文件系统和协作同步)
- 184.6 Admin and Internal Tools Optimize Correctness and Operational Control(后台管理系统更重视权限、审计、批量操作、危险操作确认、数据表格、搜索、导入导出和故障可追踪性)
- 184.7 Architecture Pattern Should Follow Product Constraint(选择 CSR、SSR、SSG、RSC、PWA、offline-first、edge、GraphQL、RPC、query cache 或 service worker)
Part 26: Framework and Toolchain Mapping Across System Paths
Chapter 185: How to Map Any Framework onto the Web System Model
- 185.1 Framework Mapping Starts from Boundaries(比较框架先画 browser/server/edge/build/database/cache 边界,再放入 route、data、mutation、rendering 和 deployment)
- 185.2 Every Framework Covers Some Paths and Leaves Others Exposed(没有框架覆盖完整 Web 系统;有的擅长 UI runtime,有的擅长 routing,有的擅长 SSR,有的擅长 API,有的擅长 build,有的只处理局部问题)
- 185.3 Rendering Path Shows Where UI Is Produced(框架是否支持 CSR、SSR、SSG、ISR、streaming、partial hydration、islands、RSC)
- 185.4 Data Path Shows Who Reads, Caches, and Revalidates Data(一个框架的数据模型需要回答:数据在哪里读取、谁负责缓存、何时刷新、如何处理错误、是否支持 streaming、是否能保护 server-only 数据)
- 185.5 Mutation Path Shows How User Intent Becomes Durable State(mutation path 要说明 form/action/API、validation、auth、transaction、side effect、cache invalidation 和 UI feedback)
- 185.6 Deployment Path Shows the Real Runtime Contract(框架在 Node、serverless、edge、static hosting、adapter、Docker、Cloudflare、Vercel、Netlify 上的行为不同)
- 185.7 Framework Comparison Must Become System Path Comparison(比较框架应该比较路径覆盖、边界清晰度、失败模式、可观测性、部署约束和逃生口,把语法、模板和社区热度放到次要位置)
Chapter 186: UI Runtime Mapping React, Vue, Svelte, Solid, and Compiler-Driven UI
- 186.1 React Maps UI to Component Reconciliation and Scheduling(React 主要把 UI 表达为组件和状态快照,通过重新渲染、reconciliation、hooks、effects 和调度机制把状态变化映射到 DOM 更新)
- 186.2 Vue Maps UI to Template, Reactivity, and Component Scope(Vue 通过 template、reactive state、computed、watch、component scope 和 compiler/runtime 协作)
- 186.3 Svelte Moves More UI Work into Compile Time(Svelte 把许多响应式分析和 DOM update 生成放到编译阶段,减少部分运行时框架成本,但也把更多语义交给 compiler 和构建产物)
- 186.4 Solid Maps UI to Fine-Grained Reactive Dependencies(Solid 更强调 fine-grained reactivity,让 signal 变化直接驱动依赖它的具体 DOM 或 computation,区别于默认组件级重新渲染)
- 186.5 Virtual DOM, Signals, and Compiler Output Are Different Change Propagation Models(不同 UI 框架的核心差异在于状态变化如何被追踪、调度、传播、批处理并落到真实 DOM)
- 186.6 UI Runtime Mapping Must Include Side Effects and Lifecycle(UI runtime mapping 需要覆盖 render、state update、effect cleanup、subscription、async race、hydration 和 teardown)
- 186.7 UI Frameworks Cover Interface Runtime, Not Full System Boundaries(说明 UI runtime 与 routing、data、mutation、identity、cache、deployment 和 server boundary 的分工)
Chapter 187: Routing and Rendering Framework Mapping
- 187.1 Full-Stack Frameworks Package Routing as an Application Boundary(Next、Remix、SvelteKit、Nuxt 等框架把 URL、layout、data、action、error、cache 和 deployment 绑定到 route)
- 187.2 Next.js Maps React to Server Rendering, App Router, RSC, and Deployment Output(Next.js 把 React UI 扩展到 SSR、SSG、ISR、streaming、RSC、server action、route handler 和多产物部署路径)
- 187.3 React Router and Remix Map Navigation to Loader and Action Semantics(React Router/Remix 用 loader、action、Form、defer、error boundary 把 navigation 转成数据和写入语义)
- 187.4 SvelteKit and Nuxt Map Framework-Specific Components to Full-Stack Routes(SvelteKit 和 Nuxt 分别把 Svelte / Vue 组件体系扩展到路由、服务端加载、API endpoint、adapter 和部署输出)
- 187.5 Astro Maps Content-Heavy Sites to Islands and Partial Interactivity(Astro 更强调内容优先、静态输出、islands architecture 和按需交互,适合把大量 HTML 保持静态,只激活需要交互的局部组件)
- 187.6 Routing Frameworks Differ in What They Treat as the Unit of Work(有些框架以 route segment 为单位,有些以 loader/action 为单位,有些以 page/layout 为单位,有些以 island 为单位)
- 187.7 Rendering Mapping Must Ask Where HTML, Data, and JavaScript Are Produced(比较全栈框架时,要明确 HTML 在哪里生成,数据在哪里读取,JavaScript 在哪里执行,交互在哪里激活,缓存由谁控制)
Chapter 188: Data Read and Mutation Mapping Across Modern Full-Stack Frameworks
- 188.1 Framework Data Model Defines How Routes Become Data Requests(框架数据模型决定 route params、loader/server component、query cache、prefetch、revalidation 如何生成请求)
- 188.2 Loader-Based Models Tie Data to Navigation(loader 模型把数据读取绑定到路由进入过程,使 navigation、redirect、error boundary 和 loading state 更容易协调)
- 188.3 Server Component Models Move Reads into Server-Side UI Trees(Server Component 模型把部分数据读取放进服务端组件树,使 UI 组合和 server-only data access 更接近,但也增加缓存、序列化和边界判断成本)
- 188.4 Query-Cache Models Treat Server State as Client-Observed Remote State(TanStack Query、SWR 等模型把 server state 看成客户端观察到的远端副本)
- 188.5 Action-Based Mutation Models Reconnect Forms with Server Boundaries(route action、server action、server function 等机制把用户提交意图重新放回 request-scoped server boundary)
- 188.6 Framework Defaults Encode Consistency Tradeoffs(自动缓存、默认 stale time、静态生成、revalidation、prefetch、mutation invalidation 等默认行为都在替开发者做一致性权衡)
- 188.7 Data Mapping Should End in a Clear Ownership Model(无论框架提供什么 API,最终都要回答:数据真相在哪里,缓存副本在哪里,谁能修改,谁负责刷新,失败时谁恢复)
Chapter 189: API and Server Runtime Framework Mapping
- 189.1 Server Frameworks Map HTTP Requests to Application Handlers(server framework 把 method、URL、headers、body、context、middleware、handler、response stream 和 error boundary 连接起来)
- 189.2 Express Represents Flexible Middleware-Centric Request Handling(Express 通过 middleware chain 和 request/response handler 模型组织通用 Node server)
- 189.3 Fastify Emphasizes Schema, Performance, and Plugin Encapsulation(Fastify 更强调 schema、hook、plugin、serialization 和性能路径)
- 189.4 Hono Maps Web Standard Request Handling Across Multiple Runtimes(Hono 偏向 Web Standard Request / Response 模型)
- 189.5 Route Handlers Collapse Server Endpoints into Full-Stack Framework Routes(Next.js、SvelteKit、Nuxt 等框架中的 route handler 把 API endpoint 放到应用路由结构附近)
- 189.6 Server Functions Hide Endpoint Shape While Keeping Server Duties(说明 server functions 隐藏 endpoint 形状后仍需输入校验、权限、错误、日志、幂等和缓存失效)
- 189.7 API Runtime Mapping Must Include Middleware, Streaming, and Failure Semantics(比较 server framework 需要同时看写法、middleware 顺序、streaming 能力、错误传播、body 处理、runtime adapter 和可观测性)
Chapter 190: Data Layer Tooling and Query Boundary Mapping
- 190.1 Data Tools Map Application Intent to Database Operations(Prisma、Drizzle、ORM、query builder、raw SQL 和 validation schema 都在不同层次上把应用意图映射到数据库查询、事务和持久化约束)
- 190.2 Prisma Emphasizes Schema-Centered Client Generation(Prisma 通过 schema、migration 和生成 client,把数据库模型、类型和查询 API 连接起来,降低常见 CRUD 与类型漂移成本)
- 190.3 Drizzle Emphasizes Type-Safe SQL-Like Query Construction(Drizzle 更接近 SQL 结构和 TypeScript 类型系统,让开发者在保持类型安全的同时更显式地控制查询形状)
- 190.4 ORM Abstraction Must Be Checked Against Query Reality(ORM 可以提升生产力,但必须用实际 SQL、索引、事务、连接池和查询计划验证,否则容易出现 N+1、过度加载和隐藏性能问题)
- 190.5 Validation Tools Define Runtime Trust Boundaries(Zod、Valibot、JSON Schema、OpenAPI schema 等工具把未知输入转为已验证数据)
- 190.6 Data Layer Mapping Must Include Migration and Compatibility(数据工具选择同时影响查询写法、schema migration、回滚、生成类型、部署顺序、serverless 连接和 edge 兼容)
- 190.7 The Best Data Tool Is the One That Makes Boundaries Explicit(好的数据层工具是让 schema、query、transaction、validation、migration、permission 和错误边界更清楚)
Chapter 191: Build and Deployment Toolchain Mapping
- 191.1 Build Tools Map Source Graphs to Runtime Artifacts(build tool 会把 source graph 转成 chunk graph、server output、asset manifest、source map、CSS 和 deployment artifact)
- 191.2 Vite Maps Development Speed to Native ESM and Production Output to Rollup(Vite 开发阶段利用原生 ESM 提升启动和 HMR 体验,生产构建默认使用 Rollup 生成优化后的静态产物)
- 191.3 Webpack Maps Everything into a Configurable Dependency Graph(Webpack 通过 loader、plugin、entry、chunk、runtime、module federation 和 asset module 构造高度可配置图)
- 191.4 Rollup Maps Libraries and ESM Graphs to Optimized Bundles(Rollup 强调 ESM 静态分析、tree shaking 和库打包能力,常被用于生产构建、library build 和工具链内部输出)
- 191.5 Turbopack Maps Large Project Builds to Incremental Graph Computation(Turbopack 目标是通过增量计算和更细粒度 graph 更新改善大型项目开发与构建体验,但仍要放回 chunk、output、runtime target 的系统路径里分析)
- 191.6 Hosting Platforms Map Artifacts to Runtime Locations(Vercel、Netlify、Cloudflare、AWS 等平台把 artifact 分配到 static hosting、serverless、edge、CDN 和 region)
- 191.7 Deployment Mapping Must Include Cache, Region, Rollback, and Environment Scope(deployment mapping 要标注 cache policy、region、env var、secret scope、preview/prod、rollback 和 migration)
Chapter 192: Framework Comparison as Boundary Comparison
- 192.1 Syntax Comparison Hides System Differences(两个框架看起来都能写页面和组件,但它们在路由、数据、缓存、server boundary、client bundle、部署产物和错误恢复上可能完全不同)
- 192.2 Feature Lists Must Be Reduced to Boundary Behavior(说明 SSR、API route、edge、form action 等功能名需要还原为执行位置、失败表达和缓存行为)
- 192.3 Defaults Are Architectural Decisions Made on Your Behalf(框架默认缓存、默认预取、默认渲染模式、默认 bundle split、默认错误边界和默认部署目标,都会替项目做架构选择)
- 192.4 Escape Hatches Reveal Framework Maturity(成熟框架需要提供 happy path,并允许开发者在数据、缓存、runtime、API、构建、部署和调试上逃出默认抽象)
- 192.5 Observability Determines Whether Abstraction Is Safe(如果框架隐藏了请求、缓存、渲染、build artifact 和 runtime failure,却不给出可观测手段,那么抽象会在故障时变成风险)
- 192.6 Framework Fit Depends on Product Constraint(文档站、SaaS dashboard、电商、协作编辑器、媒体应用、后台系统、离线 PWA 对渲染、数据、缓存、安全、部署的要求不同,框架选择也应不同)
- 192.7 The Correct Question as a Structured System(正确问题应该是:在我的产品约束下,哪个框架最清楚地封装了需要的系统路径,同时最少隐藏我必须控制的边界)
Part 27: Web Architecture Decision Framework and Engineering Tradeoffs
Chapter 193: Architecture Decision as Boundary Selection
- 193.1 Architecture Decision Starts by Locating the Boundary(先判断问题发生在 browser、server、edge、build、cache、database、third-party、deployment 哪个边界)
- 193.2 Every Boundary Has Capability, Cost, and Failure Shape(每个边界都有能力范围、成本位置和失败形态;浏览器失败表现为用户体验,服务器失败表现为请求错误,缓存失败表现为旧数据,数据库失败表现为一致性问题)
- 193.3 Moving Work Across Boundaries Changes the Whole System(把渲染从 browser 移到 server,把校验从 client 移到 server,把缓存从 client 移到 CDN,把逻辑从 origin 移到 edge)
- 193.4 Decision Quality Depends on Explicit Constraints(好的架构决策必须先列出约束:用户设备、网络、SEO、数据新鲜度、权限、成本、团队能力、部署平台、合规、可维护性和性能目标)
- 193.5 Defaults Are Hidden Architecture Decisions(框架默认值会提前决定 rendering、cache、prefetch、bundle split、runtime、error boundary 和 deployment behavior)
- 193.6 Tradeoff Matrix Is Better Than Technology Preference(把技术选择放进矩阵评估收益、代价、风险、可逆性、迁移成本、调试难度、团队熟悉度和长期维护)
- 193.7 A Good Decision Leaves Evidence and Escape Routes(好的架构决策应留下理由、边界图、指标、回滚方式、替代方案和观察点,使未来能验证、调整或迁移,降低演变成不可解释技术债的风险)
Chapter 194: Choosing CSR, SSR, SSG, ISR, Streaming, Islands, or RSC
- 194.1 Rendering Choice Answers Where HTML Is Produced and Where Interaction Starts(选择 CSR、SSR、SSG、ISR、streaming、islands、RSC,核心是在决定 HTML 由谁生成、数据在哪里读取、JavaScript 在哪里执行、交互在哪里激活)
- 194.2 CSR Fits Highly Interactive Apps with Less Public Discovery Pressure(CSR 适合强交互、登录后、状态密集、SEO 压力较小的应用,但需要承担较重的客户端 JavaScript、首屏加载和低端设备成本)
- 194.3 SSR Fits Dynamic Content That Needs Early HTML and Request Context(SSR 适合需要 request context、cookie、session、locale、权限或实时数据参与页面生成的场景,但会增加服务器计算、冷启动和运行时故障风险)
- 194.4 SSG Fits Stable Public Content and CDN Distribution(SSG 适合文档站、博客、营销页、帮助中心、公开内容页等稳定内容;它把成本前移到 build time 和 CDN cache,但需要解决内容更新和失效问题)
- 194.5 ISR and Revalidation Fit Semi-Dynamic Public Content(ISR 或类似 revalidation 模型适合内容会更新且允许请求间复用静态结果的公开页面)
- 194.6 Streaming Fits Slow Data and Progressive User Understanding(当页面有部分内容能先展示、部分数据较慢时,streaming 可以减少用户空等,但它要求 runtime、proxy、CDN、browser 和错误边界共同支持)
- 194.7 Islands and Partial Hydration Fit Content-Heavy Pages with Local Interaction(内容占主体、交互分布在局部组件的页面,适合 islands 或 partial hydration,把大部分 HTML 保持静态,只激活必要交互)
- 194.8 RSC Fits Server-Owned Data and Component-Level Boundary Control(RSC 适合希望把一部分 UI 组合和数据读取留在 server boundary 的 React 应用)
- 194.9 Rendering Choice Should Be Per Route or Per Segment(现代 Web 应按 route、segment、component、数据新鲜度和交互密度选择渲染模式组合)
Chapter 195: Choosing REST, GraphQL, RPC, Server Function, or BFF
- 195.1 API Choice Starts from Contract Ownership(选择 REST、GraphQL、RPC、Server Function 或 BFF 前,先判断接口是公开给第三方、服务多个客户端、只服务一个前端)
- 195.2 REST Fits Stable Resources and HTTP Infrastructure Participation(REST 适合资源边界清楚、希望利用 HTTP method、status、cache、ETag、proxy、CDN 和通用工具的系统)
- 195.3 GraphQL Fits Flexible Query Shape and Multi-Client Data Needs(GraphQL 适合客户端数据需求变化大、多个端需要不同字段组合、schema 能集中治理的场景,但必须控制 resolver waterfall、权限和缓存复杂度)
- 195.4 RPC Fits Action-Oriented Internal Application Contracts(RPC 适合业务动作明确、技术栈统一、客户端和服务端强协作的内部应用,但需要注意版本、互操作和运行时校验)
- 195.5 Server Function Fits Tight Full-Stack Boundaries(Server Function / Server Action 适合页面和写入逻辑紧密绑定的 full-stack 应用,可以减少 API 样板)
- 195.6 BFF Fits Frontend-Specific Aggregation and Protection(BFF 适合前端页面需要聚合多个后端服务、裁剪数据、隐藏内部拓扑、优化请求形状和保护浏览器通过明确边界接触内部系统的场景)
- 195.7 Public APIs Need Stronger Versioning Than Internal Calls(面向第三方或多客户端的 API 更需要 OpenAPI、版本、兼容策略、文档、contract test;内部 server function 可以更依赖框架约束和同步部署)
- 195.8 The Wrong API Style Usually Fails at Evolution Time(API 选错可能马上失败,但在多客户端、权限变化、性能瓶颈、版本迁移、缓存失效和团队协作时会暴露成本)
Chapter 196: Choosing Client Cache, Server Cache, CDN Cache, or Framework Cache
- 196.1 Cache Choice Starts from Data Ownership and Freshness Requirement(缓存选择首先要判断数据真相在哪里、谁能修改、多久过期、是否个性化、是否敏感、是否允许用户看到旧数据)
- 196.2 Browser and Client Query Cache Fit User-Scoped Remote State(client cache 适合用户会话内的 server state 副本、列表详情、搜索结果、后台刷新和乐观 UI,安全边界仍在服务端)
- 196.3 Server Cache Fits Expensive Backend Work with Trusted Context(server cache 适合缓存数据库查询、外部 API、权限结果、聚合数据和模板结果,但必须把 auth、tenant、locale、role 等上下文纳入缓存键)
- 196.4 CDN Cache Fits Public or Safely Segmented Responses(CDN cache 适合静态资源、公开 HTML、匿名内容、可版本化资源和全球分发;涉及 cookie、authorization 或个性化时必须特别谨慎)
- 196.5 Framework Cache Fits Rendering and Data Fetching Defaults(framework cache 适合与 route、server component、fetch、static generation、revalidation 绑定的数据)
- 196.6 Cache Key Design Is More Important Than Cache Layer Count(缓存层越多可能越好;如果 cache key、Vary、credential、locale、tenant、version 没设计好,多层缓存会放大错误)
- 196.7 Invalidation Strategy Must Be Designed Before Caching Aggressively(在大规模使用缓存前,必须先设计 mutation 后如何失效、部署后如何 purge、权限变化后如何清理、数据过期后如何重新验证)
- 196.8 Stale-While-Revalidate Is a UX and Consistency Choice(SWR 类策略需要区分万能性能优化,它意味着用户可能先看到旧内容,再看到刷新结果;是否接受取决于业务场景)
- 196.9 Cache Decision Must Include Observability and Manual Recovery(缓存系统需要能观察 hit/miss、stale、revalidate、purge、key、tag、region、version,并在出错时能手动修复或回滚)
Chapter 197: Choosing Node Runtime, Edge Runtime, Serverless, or Static Hosting
- 197.1 Runtime Choice Starts from Required Capabilities(选择 Node、edge、serverless 或 static hosting 前)
- 197.2 Static Hosting Fits Prebuilt Public Artifacts(静态托管适合 SSG、文档站、营销页、静态资源和前端 SPA;动态请求和可信服务器逻辑需要 server、edge 或 serverless runtime 承担)
- 197.3 Node Runtime Fits Full Server Capability and Long-Lived Processes(Node server 适合复杂 middleware、数据库连接池、文件处理、streaming、后台任务、长连接和更完整 server API,但需要运维、扩缩容和进程健康管理)
- 197.4 Serverless Fits Burst Traffic and Request-Scoped Work(serverless 适合按请求扩缩、低运维和事件驱动场景,但需要控制 cold start、执行时长、连接池、包体大小和无状态假设)
- 197.5 Edge Runtime Fits Low-Latency Lightweight Decisions(edge 适合地理路由、重定向、轻量鉴权、header 改写、A/B test、缓存判断和靠近用户的短逻辑,但通常不适合重事务、大依赖和长数据库连接)
- 197.6 Data Location Can Override Compute Location(把计算放到 edge 可能更快,如果数据库或对象存储远在中心区域,edge 到数据层的往返可能成为瓶颈)
- 197.7 Streaming and Long-Lived Work Must Be Tested on the Actual Platform(不同平台对 streaming、SSE、WebSocket、超时、buffering、body size 和后台任务支持不同,判断依据需要来自目标平台表现)
- 197.8 Runtime Decision Must Include Cost and Failure Model(不同 runtime 的计费方式、冷启动、region、并发、超时、日志、回滚、调试和平台锁定都不同,必须纳入架构决策)
Chapter 198: Choosing Auth, Session, Token, Tenant, and Permission Strategies
- 198.1 Auth Strategy Starts from Who the System Must Recognize(先明确系统需要识别个人用户、组织成员、管理员、机器客户端、第三方应用、匿名访客还是多租户主体)
- 198.2 Session Cookie Fits Browser-Centered Web Applications(传统 session cookie 适合浏览器 Web 应用,服务端保留权威会话,浏览器自动随请求携带 cookie)
- 198.3 Token Strategy Fits APIs, Mobile, Third-Party, and Distributed Services(token 更适合 API、移动端、第三方集成和服务间调用,但需要处理存储位置、过期、刷新、撤销、泄漏和 audience / scope)
- 198.4 OIDC and SSO Fit Federated Identity Requirements(当系统需要接入企业身份、第三方登录、统一登录或多应用身份共享时,OIDC / SSO 更合适)
- 198.5 Tenant Boundary Must Be Built into Data and Cache Design(多租户是数据隔离、缓存键、权限查询、URL、域名、日志、计费和后台任务的核心边界)
- 198.6 Permission Model Should Match Resource and Operation Complexity(简单角色、细粒度 permission、resource ownership、tenant policy、ABAC/RBAC 要匹配业务复杂度)
- 198.7 Auth State Must Be Recoverable Across Expiry and Reauthentication(用户会话过期、MFA、权限变化、退出登录和跨标签状态变化,都需要清楚的恢复路径和用户意图保留策略)
- 198.8 Security Strategy Must Be Tested as User Flows(权限需要区分只测函数返回值,还要测试登录、退出、过期、刷新、越权访问、跨租户访问、CSRF、XSS 后果和敏感操作重新认证)
Chapter 199: Choosing Data Access, Mutation, Transaction, and Consistency Strategies
- 199.1 Data Strategy Starts from Source of Truth(先判断每类数据的权威来源是数据库、第三方服务、对象存储、浏览器本地、缓存、队列还是用户设备)
- 199.2 ORM, Query Builder, and SQL Should Match Query Complexity(简单 CRUD、复杂 join、报表、全文搜索、多租户过滤、事务和性能调优对数据访问层要求不同,选择依据应来自查询复杂度、性能边界和团队维护能力)
- 199.3 Transaction Strategy Should Match Business Atomicity(订单、支付、库存、权限变更、文件元数据等需要明确哪些操作必须原子成功,哪些可以异步补偿,哪些可以最终一致)
- 199.4 Mutation Strategy Must Handle Duplicate, Retry, and Partial Failure(任何重要写入都要设计幂等、重试、冲突、回滚、补偿、状态查询和用户可见恢复)
- 199.5 Consistency Model Should Match User Promise(如果 UI 承诺“已保存”,后端就必须能保证持久化;如果只是“同步中”,系统可以采用队列、最终一致和后台重试,但必须让用户分析)
- 199.6 File and Large Asset Paths Need Separate Strategy(文件上传、图片处理、视频转码、对象存储、CDN 分发和元数据写入需要独立生命周期和清理机制)
- 199.7 Data Access Must Respect Runtime Topology(Node、serverless、edge、queue、read replica、global database、object storage 会改变连接、延迟和一致性)
- 199.8 Correct Data Architecture Is Measured by Failure Recovery(数据架构可靠的标志是冲突、超时、重复写入、迁移、回滚、权限变化和数据损坏时仍能恢复)
Chapter 200: How to Evaluate a New Web Framework Through Boundary Questions
- 200.1 Start with the Framework’s Boundary Map(先画出框架的 browser、server、edge、build、cache、database、deployment 边界和默认数据流)
- 200.2 Translate Marketing Terms into System Paths(把 SSR、server action、edge-ready、zero JS、smart cache 等术语还原成具体执行位置和失败路径)
- 200.3 Inspect What Runs Where(确认每段代码运行在 browser、server、edge、build time、worker 还是 database-adjacent runtime)
- 200.4 Inspect Generated Artifacts and Runtime Output(检查 client/server/edge bundle、manifest、route output、cache header、HTML、data payload 和 source map)
- 200.5 Test Failure Modes(用 slow network、server error、expired session、cache stale、JS disabled、hydration mismatch、rollback 验证框架真实边界)
- 200.6 Check Escape Hatches and Interoperability(框架是否允许自定义 API、接入外部数据库、控制缓存、关闭默认行为、自定义部署、替换数据层、调试构建产物,决定它能否长期服务复杂项目)
- 200.7 Compare Defaults(同样叫 SSR、cache、route action、edge support 的能力,需要逐项比较默认缓存、执行位置、错误、部署和调试路径)
- 200.8 Evaluate Observability Before Production Adoption(确认请求、缓存、server action、RSC payload、bundle split 和 deployment error 的可观测性)
- 200.9 A Framework Is Good When Its Abstractions Preserve the Web System Model(优秀框架会保留 URL、HTTP、HTML、DOM、security、cache、accessibility、deployment 的系统语义,同时提升开发效率)