5 Service Worker Caching Strategies for Your Next PWA App

栏目: IT技术 · 发布时间: 5年前

内容简介:“A service worker is a script that your browser runs in the background, separate from a web page, opening the door to features that don’t need a web page or user interaction. Today, they already include features likeIn this blog post, I’ll focus on another

5 Service Worker Caching Strategies for Your Next PWA App

“A service worker is a script that your browser runs in the background, separate from a web page, opening the door to features that don’t need a web page or user interaction. Today, they already include features like push notifications and background sync . In the future, service workers might support other things like periodic sync or geofencing.” — The Offline Cookbook

In this blog post, I’ll focus on another exciting service workers feature — intercepting and caching network requests.

Caching is one of the most exciting features of SWs. It enables us to deliver our users with a responsive and stable native-app-like experience. A web app can display some content, and perform some function, in bad network conditions and even when the user is completely offline.

We’ll cover five different caching strategies. We’ll see how and when you should implement each of them.

  • Stale-While-Revalidate
  • Cache first, then Network
  • Network first, then Cache
  • Cache only
  • Network only

I’ll address each strategy with an example to help you better understand it. You will also learn when and where to use them in your PWAs, and some assets you can use them with.


以上所述就是小编给大家介绍的《5 Service Worker Caching Strategies for Your Next PWA App》,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对 码农网 的支持!

查看所有标签

猜你喜欢:

本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们

Spark

Spark

Bill Chambers、Matei Zaharia / O′Reilly / 2017-10-31 / GBP 39.99

Learn how to use, deploy, and maintain Apache Spark with this comprehensive guide, written by the creators of the open-source cluster-computing framework. With an emphasis on improvements and new feat......一起来看看 《Spark》 这本书的介绍吧!

JSON 在线解析
JSON 在线解析

在线 JSON 格式化工具

MD5 加密
MD5 加密

MD5 加密工具

XML 在线格式化
XML 在线格式化

在线 XML 格式化压缩工具