Use case
We have an app where a website is loaded in a WKWebView instance. Within this website, there is a requirement to load certain external URLs provided by customers in iframes.
The challenge we are facing is in setting up offline support for these URLs in iframes.
So far we have tried.
1. Application Cache - In Iframes Appcache was not working correctly when the embedded domain was not exactly the same as the parent domain.
When checking for state changes on window.applicationCache. It was going from "checking" to "error" state without completing caching. - Related Bug
2. Service Workers with App Bound Domains - We tried adding some of the external domains to WKAppBoundDomains to get access to the service worker API.
Service worker API was available but it couldn't be properly used because of the following limitations.
ServiceWorkerRegistration.unregister method was always failing. - Related Bug
There is a maximum limitation of 3 service workers after which service worker register and update methods will fail. - Related Bug
3. Running an HTTP server on the app - In most cases, external URLs are static sites. In this case, it is possible to request the source files instead of the URL. We tried to host these files on a server on the app side.
The issue here was that as the parent domain is on HTTPS the source URL of the iframe also required to be a valid HTTPS URL.
Because of these issues, we are currently blocked on offline support for URLs inside iframes
The questions I have are
- Are there any workarounds for the above mentioned issues
- Is there any other way to handle our use case