简体   繁体   English

Angular PWA 在 safari 和旧浏览器上无法离线工作

[英]Angular PWA not working offline on safari and old browser

I created my PWA following this: https://angular.io/guide/service-worker-getting-started我按照以下方式创建了我的 PWA: https : //angular.io/guide/service-worker-getting-started

It works perfectly offline on my Chrome Desktop, but it does not work offiline on iOS 12 Safari or Android 5 Chrome.它可以在我的 Chrome 桌面上完美地离线工作,但它不能在 iOS 12 Safari 或 Android 5 Chrome 上离线工作。 I am accessing network with ip XXX.XXX.XXX:8080 from an localhost ssl server using http-server command.我正在使用 http-server 命令从 localhost ssl 服务器访问具有 ip XXX.XXX.XXX:8080 的网络。

I dont understand.我不明白。 I need to configure the manifest manually for old browsers and safari where service workers dont work?我需要为 Service Worker 不工作的旧浏览器和 safari 手动配置清单吗? Or my Angular PWA project generated in CLI should does everything for me?或者我在 CLI 中生成的 Angular PWA 项目应该为我做一切?

example my code https://github.com/GuilhermeLessa/teste-pwa例如我的代码https://github.com/GuilhermeLessa/teste-pwa

I am a newbie still can't stop myself typing in here, please correct me everyone!我是新手还是忍不住在这里打字,请大家指正! The max safari supports (as documented) is 50Mib (and that 50Mb is for both indexedDB and Cache Api) on mobile devices but on the desktop it says unlimited, i never had a chance to verify it.移动设备上的最大 safari 支持(如文档所示)是 50Mib(并且 50Mb 用于 indexedDB 和 Cache Api),但在桌面上它表示无限制,我从来没有机会验证它。 I developed an application using Express, Nodejs and some obvious JS.我使用 Express、Nodejs 和一些明显的 JS 开发了一个应用程序。 It works fine with Chrome, Firefox and Opera (on android devices), MS Edge 38 version doesn't seem to support it.它适用于 Chrome、Firefox 和 Opera(在 android 设备上),MS Edge 38 版本似乎不支持它。 Safari supports in a way that when offline, it loads the page, texts and images but not the videos which I assume is the reason on the 50Mib limit, as I only tried on the mobile device. Safari 支持的方式是在离线时加载页面、文本和图像,但不加载视频,我认为这是 50Mib 限制的原因,因为我只在移动设备上尝试过。 MS Edge version 42 supports almost fully (atleast on my ASUS p027) didn't get a machine with the latest MS Edge intalled. MS Edge 42 版几乎完全支持(至少在我的 ASUS p027 上)没有安装最新的 MS Edge 的机器。 Please also note that not all the old browser will support whether you mention it in the manifest or not as they are not compatible with service worker or Cache API.另请注意,并非所有旧浏览器都支持您是否在清单中提及它,因为它们与 Service Worker 或 Cache API 不兼容。 I know making an app PWA one of the steps is to have manifest file, but PWA on the other hand does work without manifest file only the score of lighthouse would be lesser than 100%.我知道制作应用程序 PWA 的步骤之一是拥有清单文件,但另一方面,PWA 在没有清单文件的情况下也能工作,只有灯塔的分数低于 100%。 So, in precise I would say old browsers don't support PWA and you will remain in trouble.所以,准确地说,我会说旧浏览器不支持 PWA,你会遇到麻烦。 Also, Chrome and Opera browsers can have storage pool of up-to 33% of available free disk space and each origin may have up-to 20% from that pool.此外,Chrome 和 Opera 浏览器可以拥有高达 33% 的可用可用磁盘空间的存储池,并且每个源最多可以有来自该池的 20%。 Firefox pool is 50% of the available free disk space but the origin may have maximum of 2048, and this is called hard limit (upper bound can be lesser than this depending on the pool). Firefox 池是可用可用磁盘空间的 50%,但源的最大值可能为 2048,这称为硬限制(上限可能小于此值,具体取决于池)。 Also, the browsers excercise LRU (Least Recently Used) policy also known as best effort on temporary storage while it doesn't apply on persistent storage.此外,浏览器在临时存储上执行 LRU(最近最少使用)策略,也称为尽力而为,但不适用于持久存储。 for chrome high site engagement, or making a site book marked (while the book marks are less than 5), adding a site to the home screen or allowing push notification, if any of these 4 option taken chrome will turn it into persistent storage so the LRU won't take place on it.对于 chrome 高站点参与度,或标记站点书籍(当书签小于 5),将站点添加到主屏幕或允许推送通知,如果这 4 个选项中的任何一个被采用,chrome 将把它变成持久存储,所以LRU 不会发生在它上面。 Where as in Firefox, you have to explicitly code it and the browser ask using a pop-up if the user is happy for the persistent storage or not.与在 Firefox 中一样,您必须对其进行显式编码,并且浏览器会使用弹出窗口询问用户是否对持久存储感到满意。 I know I have diverted but it all comes under PWA.我知道我已经改道了,但这一切都在 PWA 之下。 Hope you will get better answer.希望你能得到更好的答案。 Cheers:)干杯:)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM