博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
[PWA] Cache JSON Data in a React PWA with Workbox, and Display it while Offline
阅读量:6974 次
发布时间:2019-06-27

本文共 854 字,大约阅读时间需要 2 分钟。

We can view the PWA offline because we are caching the static and CDN assets for the app - but the list of todo items won't display, because those API calls are not being cached. We'll add another route to the service worker, to store the result of any .json API call from our server. Then, we'll be able to view the app with the entire list of items offline.

 

When we want to cache json file from our server:

workbox.skipWaiting();workbox.clientsClaim();workbox.routing.registerRoute(    new RegExp('https:.*min\.(css|js)'),    workbox.strategies.staleWhileRevalidate({        cacheName: 'cdn-cache'    })  )// Cache the json files from our server// for both production and dev '/'  workbox.routing.registerRoute(    new RegExp('/.*:4567.*\.json'),    workbox.strategies.networkFirst()  )workbox.precaching.precacheAndRoute(self.__precacheManifest || [])

 

转载地址:http://gwrsl.baihongyu.com/

你可能感兴趣的文章
数字签名与数字证书技术简介
查看>>
[LNMP]Nginx解析php与代理
查看>>
GridView动态添加新行
查看>>
使用Kazoo去增删改查zookeeper
查看>>
C# 实现系统关机、注销、重启、休眠、挂起
查看>>
SQL server 2000常用字符串长度总结
查看>>
征服Perl——哈希——里程碑M7
查看>>
遇到女神应该使用什么样的暗恋思维
查看>>
HA(heartbeat)主备模式实现lvs群集的高可用性
查看>>
mtr路由监控
查看>>
容器编排 Docker Compose
查看>>
KVM 使用virtio驱动Windows server 虚拟机
查看>>
我的Oracle 9i学习日志(15)-- 表的管理
查看>>
mysql5.7更改密码
查看>>
adb无线网络调试
查看>>
Nginx+Keepalived搭建高可用负载均衡集群
查看>>
防火墙示例-用简单规则集保护网络
查看>>
记一次开发过程中的思维转换
查看>>
8. Accordion模拟菜单,Accordion动态绑定数据,模拟菜单点击
查看>>
基于Spring源码分析AOP的实现机制
查看>>