[PWA] Cache JSON Data in a React PWA with Workbox, and Display it while Offline
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 || [])
[PWA] Cache JSON Data in a React PWA with Workbox, and Display it while Offline的更多相关文章
- directly receive json data from javascript in mvc
if you send json data to mvc,how can you receive them and parse them more simply? you can do it like ...
- Guzzle Unable to parse JSON data: JSON_ERROR_SYNTAX - Syntax error, malformed JSON
项目更新到正式平台时,出现Guzzle(5.3) client get请求出现:Unable to parse JSON data: JSON_ERROR_SYNTAX - Syntax error, ...
- SQL to JSON Data Modeling with Hackolade
Review: SQL to JSON data modeling First, let’s review, the main way to represent relations in a rela ...
- SyntaxError: JSON.parse: unexpected character at line 1 column 1 of the JSON data错误的解决
记录个报错: 问题描述: 经过服务器生成图片返到前台时,在火狐浏览器中下载图片或打开图片时报错:SyntaxError: JSON.parse: unexpected character at lin ...
- SyntaxError: JSON.parse: bad control character in string literal at line 1 column 16 of the JSON data
JSON.parse转化Json字符串时出现:SyntaxError: JSON.parse: bad control character in string literal at line 1 co ...
- PHP convet class to json data
/********************************************************************* * PHP convet class to json da ...
- json data 解析demo
json data: demo: JsonObject jsonObject= JsonHandle.getAsJsonObject(city_dataInfo).get("data&quo ...
- jQuery解析JSON出现SyntaxError: JSON.parse: unexpected character at line 1 column 2 of the JSON data
SyntaxError: JSON.parse: unexpected character at line 1 column 2 of the JSON data 我在使用$.parseJSON解析后 ...
- jstree中json data 的生成
jstree中json data 的生成 jstree官网上给出的json数据格式是这样的: <span style="font-size:14px;">// A ...
随机推荐
- 学习C++ -> 向量(vector)
一.向量的介绍 向量 vector 是一种对象实体, 能够容纳许多其他类型相同的元素, 因此又被称为容器. 与string相同, vector 同属于STL(Standard Template Lib ...
- Jquery CheckBox 选中和非选中
if($("input[name='is_pay']").prop('checked')) { $("input[name='is_pay']").prop(' ...
- rootkit 内核函数hook
转自:https://0x90syntax.wordpress.com/2016/02/21/suterusu-rootkitx86%e4%b8%8earm%e7%9a%84%e5%86%85%e8% ...
- cocos2d-iphone心得
源码下载地址: http://code.google.com/p/cocos2d-iphone/downloads/list https://github.com/cocos2d/cocos2d-ip ...
- UVA 10910 Marks Distribution
题意 把数字T分成N个数的和,保证这N个数中最小的数大于P.求方案数目 另f[i][j]表示把i分成j个数的和的方案数 f[i][j]=f[i][j-1]+f[i-1][j-1]+f[i-2][j-1 ...
- snmp 学习
SNMP:“简单网络管理协议”,用于网络管理的协议.SNMP用于网络设备的管理.SNMP的工作方式:管理员需要向设备获取数据,所以SNMP提供了“读”操作:管理员需要向设备执行设置操作,所以SNMP提 ...
- hdu 5138(水题)
题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5138 反着来. #include<iostream> #include<cstdi ...
- NEUQOJ 1999: 三角形or四边形?【搜索联通块/模拟】
http://newoj.acmclub.cn/problems/1999 1999: 三角形or四边形? 描述 题目描述: JiangYu很无聊,所以他拿钉子在板子上戳出了一个由.#组成的10*10 ...
- Python的网络编程[1] -> FTP 协议[1] -> 使用 pyftplib 建立 FTP 服务器
使用 pyftplib 建立 FTP 服务器 pyftplib 主要用于建立 FTP Server,与 ftplib 建立的 Client 进行通信. 快速导航 1. 模块信息 2. 建立 FTP 服 ...
- nginx+tomcat负载使用
Nginx+Tomcat搭建 版本 操作系统版本 Centos 6.4 Nginx版本 nginx-1.3.15.tar.gz JDK版本 jdk-7u71-linux-i586 //jdk1.7 ...