Safari service worker work incorrect with custom offline page

I created a pwa version of the site with a custom offline page using the service worker. https://ohladkov.github.io/ When navigating through pages, they are added to the cache, and when they are visited again, it is shown from the cache. When you click on a link and do not connect to the Internet and this page is not cached, an offline page is displayed.

User uploaded file

There are 2 options to refresh the page:

When the Internet appears on the offline page, a link appears to update the page.

User uploaded file

When the Internet appears, return to any available page (home
page) and go to the desired page.

User uploaded file

With the first option there is no problem. And with the second there is a problem in the safari. The problem occurs when:

  1. clicked on the link without an Internet connection and received an offline page
  2. The next time already with the Internet connection went on the same link and again received an offline page, although it should show an online page

Steps to reproduce the problem:

  1. go to the site with the Internet turned on
  2. turn off the Internet
  3. go to page1.html (an offline page is displayed)
  4. go back to index.html (go home link)
  5. turn on the internet
  6. go back to page1.html (an offline page is displayed, but page1.html should be displayed)
  7. go to page2.html - everything works correctly, the online page loads

Who faced such a problem? It seems that the safari remembers request-response bunch and return the same result, regardless of the connection to the Internet.

Code here: https://github.com/ohladkov/ohladkov.github.io/blob/master/sw.js

iPhone 8, iOS 11.3.1, null

Posted on May 24, 2018 5:51 AM

Reply

Similar questions

There are no replies.

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

Safari service worker work incorrect with custom offline page

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.