[io PWA] Great libraries and tools for great Progressive Web Apps

  • sw-toolbox: Github
    •   It provides a cononical implementation of all the runtime caching strategies that you need for you dynamice content.
  • sw-precache: Github
    •   It takes care of caching and maintaing all the resources in your app shell
  • sw-helpers: Github
  • lighthouse: Github

 

 

sw-toolbox:

For the assets, you can use cache-first:

CacheFirst, will go to cache for fetching data, if there is then return the cache back, will not go to network for fetching data.

If cannot get the data from the cache, then fallback to network to get data.

toolbox.router.get(
    '/path/to/images/.*',
    toolbox.cacheFirst,
    {cache: {
        name: 'images',
        maxEnteries: 6  // cache at most 6 images
    }}
)

 

For highly dynamic data, can use network first: (Battle Lie-Fi)

NetworkFirst, will go network for fetching data, if get the data then return back.

If cannot get the data, then fallback to cache.

toolbox.router.get(
    '/posts/.*',
    toolbox.networkFist,
    {cache: {
        name: 'posts',
        maxEnteries: 500,
        maxAgeSeconds: 5 * 24 * 60 * 60
    },
   networkTimeoutSeconds: 3 // after three sconds, fallback to cache
  } )

 

Fastest: 

Race between cache and network:

 

 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值