Test offline browsing with Android Chrome

时间:2016-07-11 22:58:40

标签: offline-caching service-worker offline-mode

I am trying to build an offline-data persistent web application with Service Workers. I managed to have it working on my laptop Chrome (51) and it loads the cached files and displays an offline message when I simulate being offline via the Chrome DevTools - Network tab. I uploaded the application to github to make sure it is available with https (https://mguardos.github.io/index.html)

However, when I try to test it with my Android Chrome (Nexus 5 - Android 6.0.1 - Chrome 51), the application loads fine when online, but if I set the plane mode on and reload the page, the browsers is not checking the service worker but displaying the offline message directly

"You are offline. Your devide is offline. Try: ... ERR_INTERNET_DISCONNECTED"

Is there any option that I have to enabled in my Android Chrome for Service workers to work?

Thanks for any tip

PS (edited): Same issue occurs with Opera 37 on Android 6.0.1. However, the Registration service happens properly for both Chrome and Opera in the background (validated via an alert upon the registration method is successfully completed)

PSS: The link above tries to be a very basic example of combining service workers with AppCache, to retrieve localStorage and IndexedDB data so any constructive critic would be very much appreciated on top of the original question

1 个答案:

答案 0 :(得分:0)

Chrome中的问题似乎是需要将' /' 条目添加到要为服务工作者缓存的文件中。我添加了这个条目,我可以看到应用程序在我的Android下线时工作正常

然而,Opera的问题仍然存在,我甚至可以使用https://airhorner.com应用程序复制它

  • Just Open Opera(确保您之前清理缓存)
  • 转到https://airhorner.com(应用程序加载正常 - 虽然听起来不响)
  • 激活飞行模式
  • 重新加载页面(应用程序仍然加载,因为它正在从本地缓存中读取)
  • 关闭浏览器或只是转到其他地址
  • 然后返回https://airhorner.com(我添加到原始问题的离线消息)

我会继续调查,并且可能会为Opera浏览器创建一个新问题,因为此问题已针对Chrome进行了解答