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. webservice soapheader验证方法

    using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.We ...

  2. Oracle 整理

    高效分页 select * from ( select rownum r,a from yourtable order by name ) --之所以没有把<=20放在最外面,也就是我一直用的写 ...

  3. YYH的积木(NOIP模拟赛Round 6)

    题目描述 YYH手上有n盒积木,每个积木有个重量.现在他想从每盒积木中拿一块积木,放在一起,这一堆积木的重量为每块积木的重量和.现在他想知道重量最少的k种取法的重量分别是多少. 输入输出格式 输入格式 ...

  4. VS2013 Sqlite3 操作指令

    extern "C"{ #include "sqlite3.h" }; #pragma comment(lib,"sqlite.lib") ...

  5. shiro配置参考(一)

    <?xml version="1.0" encoding="UTF-8"?> <beans xmlns:xsi="http://ww ...

  6. java中数组有没有length()方法?string没有lenght()方法?

    java中数组有没有length()方法,求数组的长度可以使用数组的length属性. int[] arr={1,2,3,4,5}; int length=arr.length;//求数组的长度 -- ...

  7. pymongo.errors.BulkWriteError错误排解

    在mongodb进行数据库操作的时候触发异常   pymongo Error: pymongo.errors.BulkWriteError: batch op errors occurred 这种问题 ...

  8. 无类型指针 在delphi中可以直接赋值任何指针类型。

  9. sersync+rsync作实时同事

    http://liubao0312.blog.51cto.com/2213529/1677586 配置搞定,参照上面的文章,用时搞一搞就OK. 注意IPTABLES的配置及环境变量 最简陋配置: rs ...

  10. react this.props.form异步执行问题

    最近在做一个选择器联动时,碰到this.props.form的异步执行问题,导致选择器一直没有办法联动 如图,选择公司名称后,应该同步刷新门店选择默认值, 但同时又要清空门店选择的上一次记录 就用到了 ...