# Service worker in production # 产品环境下的 Service Worker This page is a reference for deploying and supporting production apps that use the Angular service worker. It explains how the Angular service worker fits into the larger production environment, the service worker's behavior under various conditions, and available recourses and fail-safes. 本页讲的是如何使用 Angular Service Worker 发布和支持产品环境下的应用。 它解释了 Angular Service Worker 如何满足大规模产品环境的需求、Service Worker 在多种条件下有哪些行为以及有哪些可用的资源和故障保护机制。 #### Prerequisites #### 前提条件 A basic understanding of the following: 对下列知识有基本的了解: * [Service Worker Communication](guide/service-worker-communications). [与 Service Worker 通讯](guide/service-worker-communications).
## Service worker and caching of app resources ## Service Worker 与应用资源的缓存 Conceptually, you can imagine the Angular service worker as a forward cache or a CDN edge that is installed in the end user's web browser. The service worker's job is to satisfy requests made by the Angular app for resources or data from a local cache, without needing to wait for the network. Like any cache, it has rules for how content is expired and updated. 从概念上说,你可以把 Angular Service Worker 想象成一个转发式缓存或装在最终用户浏览器中的 CDN 边缘。 Service Worker 的工作是从本地缓存中满足 Angular 应用对资源或数据的请求,而不用等待网络。 和所有缓存一样,它有一些规则来决定内容该如何过期或更新。 {@a versions} ### App versions ### 应用的版本 In the context of an Angular service worker, a "version" is a collection of resources that represent a specific build of the Angular app. Whenever a new build of the app is deployed, the service worker treats that build as a new version of the app. This is true even if only a single file is updated. At any given time, the service worker may have multiple versions of the app in its cache and it may be serving them simultaneously. For more information, see the [App tabs](guide/service-worker-devops#tabs) section below. 在 Angular Service Worker 的语境下,“版本”是指用来表示 Angular 应用的某一次构建成果的一组资源。 当应用的一个新的构建发布时,Service Worker 就把它看做此应用的一个新版本。 就算只修改了一个文件,也同样如此。 在任何一个给定的时间,Service Worker 可能会在它的缓存中拥有此应用的多个版本,这几个版本也都能用于提供服务。 要了解更多,参见稍后的 [App 选项卡](guide/service-worker-devops#tabs)。 To preserve app integrity, the Angular service worker groups all files into a version together. The files grouped into a version usually include HTML, JS, and CSS files. Grouping of these files is essential for integrity because HTML, JS, and CSS files frequently refer to each other and depend on specific content. For example, an `index.html` file might have a `