Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PWA专题 - ServiceWorker #41

Open
kangschampagne opened this issue May 10, 2018 · 0 comments
Open

PWA专题 - ServiceWorker #41

kangschampagne opened this issue May 10, 2018 · 0 comments
Labels

Comments

@kangschampagne
Copy link
Owner

@kangschampagne kangschampagne commented May 10, 2018

什么是 ServiceWorker?

image
Service Workers 只是后台运行的 worker 脚本。它们是用 JavaScript 编写的,只需短短几行代码,它们便可使开发者能够拦截网络请求,处理推送消息并执行许多其他任务。有几个特点:运行在它自己的全局脚本上下文中;不绑定到具体的网页;无法修改网页中的元素,因为它无法访问 DOM;只能使用 HTTPS;

在学习这个好用的家伙之前,我创建了一个 GitHub page,因为它使用 https,可以很方便的进行线上的调试。仓库地址:https://github.com/OmeletRice/learn-serviceworker

在学习 ServiceWorker 之前,我们应该熟悉哪些 Web API 呢?

  1. WebAPI - Cache
  2. WebAPI - FetchEvent

目前完成例子如下:(逐步更新)

  1. 缓存策略 - network and cache 解释
  2. 缓存策略 - cache only 解释
  3. 缓存策略 - cache and update 解释
  4. 缓存策略 - cache update and refresh 解释
  5. 缓存策略 - embedded fallback 解释
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
1 participant
You can’t perform that action at this time.