PWA - service worker - Workbox(未完)
Get Started(开始)
- 只有get请求才能cache缓存吗?
Create and Register a Service Worker File(创建和注册 Service Worker)
- Before we can use Workbox, we need to create a service worker file and register it to our website.(在使用Workbox之前,我们需要创建一个服务工作者文件并将其注册到我们的网站。)
<script>
if ('serviceWorker' in navigator) {
// Use the window load event to keep the page load performant(使用窗口加载事件保持页面加载性能)
window.addEventListener('load', () => {
navigator.serviceWorker.register('/service-worker.js');
});
}
</script>
- Looking in the “Application” tab in Chrome DevTools you should see your service worker registered.(在chrome devtools中的“application”选项卡中,您应该看到服务工作者已注册。)
- Click the “Update on reload” checkbox to make it easier to develop with your new service worker.(单击 “Update on reload” 复选框,以便与新的 service worker 一起开发。)
Importing Workbox(导入工作框)
- To start using Workbox you just need to import the workbox-sw.js file in your service worker.(要开始使用Workbox,只需在服务工作者中导入Workbox-sw.js文件。)
- Importing workbox-sw.js will create a workbox object inside of your service worker, and that instance is responsible for importing other helper libraries, based on the features you use.(导入workbox-sw.js将在服务工作者内部创建一个workbox对象,该实例负责根据您使用的功能导入其他助手库。)
- Due to restrictions in the service worker specification, these imports need to happen either inside of an install event handler, or synchronously in the top-level code for your service worker.(由于 service worker 规范中的限制,这些导入需要在安装事件处理程序内部或在服务工作者的顶级代码中同步进行。?)
importScripts('https://storage.googleapis.com/workbox-cdn/releases/4.3.1/workbox-sw.js'); // 同步的
if (workbox) {
console.log(`Yay! Workbox is loaded
PWA - service worker - Workbox(未完)的更多相关文章
浏览器缓存和Service Worker @billshooting 2018-05-06 字数 6175 Follow me on Github 标签: BOM 1. 传统的HTTP浏览器缓存策略 ...
PWA & Service Workers 版本更新 bug PWA & Service Worker https://developer.mozilla.org/zh-CN/docs ...
PWA(Progressive Web App)是前端的大趋势,它能极大的加快前端页面的加载速度,得到近乎原生 app 的展示效果(其实难说).PWA 其实是多种前端技术的组合,其中最重要的一个技术就 ...
渐进式 Web 应用(PWA) 运用现代的 Web API 以及传统的渐进式增强策略来创建跨平台 Web 应用程序. PWA 的优势 可被发现 易安装 manifest(https://develop ...
In some rare cases, you need to ask user to refresh the browsser to update the version. Maybe becaus ...
Once serive worker is registered, the first time we go to the app, we cannot see the logs from servc ...
Service worker stays between our browser and noetwork requests. It can help to fetch data from cache ...
Service Workers get installed and activated in the background, but until we reload the page they don ...
Service Worker 随着前端快速发展,应用的性能已经变得至关重要,关于这一点大佬做了很多统计.你可以去看看. 如何降低一个页面的网络请求成本从而缩短页面加载资源的时间并降低用户可感知的延时是 ...
随机推荐
带你简单了解域名系统DNS 一.域名简介 1.1.DNS服务的作用 负责解析域名,将域名解析成IP地址. 1.2.域名系统概述 由于32位的IP地址并不容易记忆,人们往往喜欢记忆网站的域名.所以当我们 ...
论文来自Mikolov等人的<Efficient Estimation of Word Representations in Vector Space> 论文地址: 66666 论文介绍了 ...
论文地址:基于通用传递函数GSC和后置滤波的语音增强 博客作者:凌逆战 博客地址:https://www.cnblogs.com/LXP-Never/p/12232341.html 摘要 在语音增强应 ...
微信小程序仿朋友圈功能开发(发布.点赞.评论等功能) 1.项目分析 项目整体分为三个部分 发布 展示 详情页 graph LR 朋友圈发布 --内容发布--> 内容展示 内容展示 --点击展示卡 ...
本笔记摘抄自:https://www.cnblogs.com/PatrickLiu/p/7792973.html,记录一下学习过程以备后续查用. 一.引言 今天我们要讲结构型设计模式的第六个模式--享 ...
CSS文本属性可定义文本的外观,这是毫无疑问的,其次css可以通过以下属性改变文字的排版,比方说letter-spacing实现字符间距text-indent: 2em;完成首行缩进2字符word-s ...
1.core-site.xml <configuration> <property> <name>fs.defaultFS</name> <val ...
everspin提供了8/16-bit的DDR4-1333MT/s(667MHz)接口,但与较旧的基于DDR3的MRAM组件一样,时序上的差异使得其难以成为DRAM(动态随机存取器)的直接替代品. ...
参考链接https://docs.docker.com/install/linux/docker-ce/centos/ 第一步,确定是centos7及以上版本 cat /etc/redhat-rele ...
一.字符串常用的方法 package com.bjpowernode.java_learning; public class D73_StringMethodBriefIntroduction { ...