我应该在服务工作者中缓存manifest.json

时间:2017-08-02 14:06:03

标签: javascript html5 service-worker

我正在使用服务工作者。我应该缓存我的manifest.json。这有道理吗? 浏览器获取此文件的频率也是如此。

2 个答案:

答案 0 :(得分:8)

Yes you should cache your manifest.json file, because if you a building a PWA, then it must have a functionality to Add to home screen. In your manifest file, it contains a start_url that needs to be cached by service worker and should return a 200 response when offline.

Let's assume anyone is offline browsing your app and hasn't added the web app on home screen, then it will ask user if he/she wants to add to home screen or not provided you have cached your manifest file.

答案 1 :(得分:1)

在每个页面加载时调用它(假设它不是SPA)。它也是静态的,不妨在我看来缓存它可以省去为该文件调用服务器的麻烦。