[PWA] 11. Serve skeleton cache for root

Intead of cache the root floder, we want to cache skeleton instead.

self.addEventListener(‘install‘, function (event) {
    event.waitUntil(
        caches.open(staticCacheName).then(function (cache) {
            return cache.addAll([
                ‘/skeleton‘,
                ‘js/main.js‘,
                ‘css/main.css‘,
                ‘imgs/icon.png‘,
                ‘https://fonts.gstatic.com/s/roboto/v15/2UX7WLTfW3W8TclTUvlFyQ.woff‘,
                ‘https://fonts.gstatic.com/s/roboto/v15/d-6IYplOFocCacKzxwXSOD8E0i7KZn-EPnyo3HZu7kw.woff‘
            ]);
        })
    );
});

Respond to requests for the root page with thepage skeleton from the cache:

self.addEventListener(‘fetch‘, function (event) {
    // use the page skeleton from the cache
    let requestUrl = new URL(event.request.url);
    if(requestUrl.origin === location.origin){
        if(requestUrl.pathname === ‘/‘){
            event.respondWith(
                caches.match(‘/skeleton‘)
            );
            return;
        }
    }

    event.respondWith(
        caches.match(event.request).then(function (response) {
            return response || fetch(event.request);
        })
    );
});
时间: 2024-08-07 00:18:01

[PWA] 11. Serve skeleton cache for root的相关文章

mysql5.7.11编译安装以及修改root密码小结

系统是cenos6.7 64位的,默认mysql5.7.11下载到/usr/local/src,安装目录在/app/local/mysql目录下,mysql数据放置目录/app/local/data.mysql从5.1后采用cmake方式编译安装,所以要先编译安装cmake工具,也可以采用yum方式安装cmake.从mysql5.7开始编译安装需要boost库的支持,所以也要下载boost库 #wget http://mirrors.sohu.com/mysql/MySQL-5.7/mysql-

[PWA] 8. Delete old cache and only keep one

So once you modify the code, service worker will auto create a new one and it won't take control over until the previous service work total die(close the tab or nav to a new url). The new service work is in the waiting list. Now what we want to do is

ORACLE 11.2.0.1升级到11.2.0.3

ORACLE 11.2.0.1升级到11.2.0.3 最近听了李光老师的关于oracle的升级公开课,深有感悟,之前一直想自己测试的,没有下定决心,这几天自己在虚拟机上测试了一下,测试的过程如下,当然这个只是一些基本的步骤,实际的生产环境我想比这个复杂的多了,但是不用急,慢慢来,循序渐进吧... 1. 数据库情况 单实例非ASM存储 ORACLE_SID : orcl ORACLE_HOME: /u01/app/oracle/product/11.2.0/dbhome_1 1. 数据库原始状态

cache目录没有权限

今天部署了新服务器发现cache目录没有权限, App 26772 stderr: Started GET "/investors" for 103.238.226.130 at 2015-08-25 11:25:47 +0800 App 26772 stderr: Processing by InvestorsController#index as HTML App 26772 stderr: Read fragment views/investors/1-2015082503242

hexo 博客支持PWA和压缩博文

目标网站 https://blog.rmiao.top/ PWA yarn add hexo-offline 然后在root config.yml里新增 # offline config passed to sw-precache. service_worker: maximumFileSizeToCacheInBytes: 5242880 staticFileGlobs: - /**/*.{js,html,css,png,jpg,gif,svg,eot,ttf,woff,woff2} - /l

SLE 11 sp4 搭建安装服务器

目录 一.SLE简介 1.1 SLE的安装包 1.2 SLE的开发包 1.3 挂在ISO 二.安装httpd服务 2.1 安装依赖环境 2.2 安装createrepo 2.3 创建repomd.xml文件 2.4 安装apache2 2.4.1 配置临时的repo仓库 2.4.2 查看repo仓库 2.4.3 开始安装apache2 2.5 修改httpd的配置文件 2.5.1 修改/etc/apache2/http.conf 2.5.2 修改/etc/apache2/default-serv

Java知识点11 Hibernate多对多单向关联(Annotation+XML实现)

1.Annotation 注解版 1.1.应用场景(Student-Teacher):当学生知道有哪些老师教,但是老师不知道自己教哪些学生时,可用单向关联的多对多模式 1.2.创建Teacher类和Student类 1 package com.shore.model; 2 3 import javax.persistence.Entity; 4 import javax.persistence.GeneratedValue; 5 import javax.persistence.Generati

LeetCode OJ - Sum Root to Leaf Numbers

这道题也很简单,只要把二叉树按照宽度优先的策略遍历一遍,就可以解决问题,采用递归方法越是简单. 下面是AC代码: 1 /** 2 * Sum Root to Leaf Numbers 3 * 采用递归的方法,宽度遍历 4 */ 5 int result=0; 6 public int sumNumbers(TreeNode root){ 7 8 bFSearch(root,0); 9 return result; 10 } 11 private void bFSearch(TreeNode ro

[转]Mariadb的root密码忘记后的解决方法

环境背景:CentOS 7.2     一.编辑/usr/lib/systemd/system/mariadb.service 文件,在Service段中添加 1 2 3 4 5 6 7 8 9 10 11 12 [Service] Type=simple User=mysql Group=mysql User=mysql Group=mysql ExecStartPre=/usr/libexec/mariadb-prepare-db-dir %n # Note: we set --basedi