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的更多相关文章

  1. 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 ...

  2. 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, ...

  3. 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 ...

  4. SyntaxError: JSON.parse: unexpected character at line 1 column 1 of the JSON data错误的解决

    记录个报错: 问题描述: 经过服务器生成图片返到前台时,在火狐浏览器中下载图片或打开图片时报错:SyntaxError: JSON.parse: unexpected character at lin ...

  5. 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 ...

  6. PHP convet class to json data

    /********************************************************************* * PHP convet class to json da ...

  7. json data 解析demo

    json data: demo: JsonObject jsonObject= JsonHandle.getAsJsonObject(city_dataInfo).get("data&quo ...

  8. 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解析后 ...

  9. jstree中json data 的生成

       jstree中json data 的生成 jstree官网上给出的json数据格式是这样的: <span style="font-size:14px;">// A ...

随机推荐

  1. PHP持久进程

    在有些业务需求中,一个业务逻辑会涉及很多其他模块,这时可以把不需要返回的数据,扔到后台异步处理(比如注册时邮件验证,发邮件这个过程就可以扔到后台处理). 这个时候可以在后台起一个PHP进程,轮循处理业 ...

  2. redis 的命令总结

    此博客为技术收集和个人的学习积累,如侵犯了您的权益,请联系我,我会及时删除,谢谢 [Redis] redis-cli 命令总结 Redis提供了丰富的命令(command)对数据库和各种数据类型进行操 ...

  3. 64位操作系统安装32位客户端和PL/SQL

    PL/SQ只能使用32位的Oracle客户端.在64位系统下安装了64位的oracle 11g,使用PL/SQL需再安装32位Oracle客户端. 按以下方法试验成功: 1)安装32位的Oracle客 ...

  4. 疫情控制(NOIP2012)庆祝2012满贯!٩(๑•◡-๑)۶ⒽⓤⒼ

    丧病至极的D2T3啊! 好吧~ 先放个传送门~ 原题传送门 好吧,这道题呢.. 根据题意我们可以很明显的看出来 军队往上走的越多(在没到根节点之前),效益一定越大.. 所以可以分情况讨论: 对于无法走 ...

  5. 高级全局API钩取 - IE连接控制

    @author: dlive @date: 2017/02/14 0x01 调试IE进程 常见网络连接库:ws2_32.dll(套接字),wininet.dll,winhttp.dll 使用Proce ...

  6. 通过OpenGL ES在iOS平台实践增强现实(一)

    http://ios.9tech.cn/news/2013/1108/38495.html 1.本文采用OpenGL ES 1固定渲染管线实现,目标为在设备拍摄到的现实世界中,绘制世界坐标轴,并根据设 ...

  7. XML技术总结之XDocument 和XmlDocument

    引言 虽然现在Json在我们的数据交换中越来越成熟,但XML格式的数据还有很重要的地位. C#中对XML的处理也不断优化,那么我们如何选择XML的这几款处理类 XmlReader,XDocument ...

  8. spring3.2事物配置异常

    异常如下: org.springframework.beans.factory.support.DefaultListableBeanFactory@1b4c1d7: defining beans [ ...

  9. Http与RPC通信协议的比较

    OSI网络结构的七层模型 各层的具体描述如下: 第七层:应用层     定义了用于在网络中进行通信和数据传输的接口 - 用户程式:提供标准服务,比如虚拟终端.文件以及任务的传输 和处理:  第六层:表 ...

  10. 基于django rest framework的mock server实践

    网上找了一下mock server的实现,发现python的基本都是基于flask来实现的,因最近在学django,就尝试用drf实现了下: A brief introduction of sui_m ...