码迷,mamicode.com
首页 > 移动开发 > 详细

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

时间:2016-05-23 22:31:15      阅读:317      评论:0      收藏:0      [点我收藏+]

标签:

  • 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:

技术分享

 

技术分享

 

技术分享

 

技术分享

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

标签:

原文地址:http://www.cnblogs.com/Answer1215/p/5521609.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!