service-worker

Angular Service Worker - Failed to load resource: the server responded with a status of 504 (Gateway Timeout)

五迷三道 提交于 2019-12-02 21:03:28
I am using the Angular-CLI 1.6.6 and @angular/service-worker 5.2.5 in our Angular 5.2.5 app. Everything works fine on the local lite-server, as well as on the production server, except for one error message popping in our production environment: Failed to load resource: the server responded with a status of 504 (Gateway Timeout) Looking into the ngsw-worker.js script I found the lines (2466 following) where the error message above is generated: async safeFetch(req) { try { return await this.scope.fetch(req); } catch (err) { this.debugger.log(err, `Driver.fetch(${req.url})`); return this

Service Worker vs Shared Worker

こ雲淡風輕ζ 提交于 2019-12-02 20:13:38
What is the difference between Service Worker and Shared Worker? When should I use Service Worker instead of Shared Worker and vice versa? A service worker has additional functionality beyond what's available in shared workers, and once registered, they persist outside the lifespan of a given web page. Service workers can respond to message events, like shared workers, but they also have access to additional events. Handling fetch events allows service workers to intercept any network traffic (originating from a controlled page) and take specific actions, including serving responses from a

How to use service workers in Cordova Android app?

荒凉一梦 提交于 2019-12-02 18:50:07
I want to use a service worker in my Cordova Android add as a convenient way to sync some images to and from the server. I notice that this question states that this is not possible, since service workers must be loaded via https: , whereas Cordova will load files via file: . On the other hand, it seems that ionic supports service workers . That implies that they have figured out some way to make this work. However, I am not using ionic. There appears to be a cordova plugin for service workers for iOS , but as I said I am on Android. What is the current best practices for using service workers

Can I have multiple service workers both intercept the same fetch request?

半腔热情 提交于 2019-12-02 18:07:34
I'm writing a library which I will provide for 3rd parties to run a service worker on their site. It needs to intercept all network requests but I want to allow them to build their own service worker if they like. Can I have both service workers intercept the same fetches and provide some kind of priority/ordering between them? Alternatively is there some other pattern I should be using? Thanks No, you can not. Only one service worker per scope is allowed to be registered so the latest kick the previous one out unless the scope is more specific, in this case, the request is attended by the

Chrome install Service Worker addAll failed to fetch

可紊 提交于 2019-12-02 16:30:05
问题 I am using a service worker to provide caching for my site's assets (HTML, JS, CSS). When I use Firefox my sw.js is installed correctly and the required files cached. If I go into offline mode I get the site styled correctly with everything present but the data (which is correct as the data is not being cached). However when I use Chrome I'm getting a TypeError: Failed to fetch error. I'm really unsure why I'm getting this error since it works in Firefox. In addition I'm getting the same

Chrome install Service Worker addAll failed to fetch

旧巷老猫 提交于 2019-12-02 12:26:52
I am using a service worker to provide caching for my site's assets (HTML, JS, CSS). When I use Firefox my sw.js is installed correctly and the required files cached. If I go into offline mode I get the site styled correctly with everything present but the data (which is correct as the data is not being cached). However when I use Chrome I'm getting a TypeError: Failed to fetch error. I'm really unsure why I'm getting this error since it works in Firefox. In addition I'm getting the same error thrown whenever the fetch event fires and the request if for an asset that is not in the cache (and

Service Worker: files are updated on the server but old version showing in browser

会有一股神秘感。 提交于 2019-12-02 07:49:01
问题 I am building a static app with PouchDB on Google AppEngine. When I open the site in a browser window, it is showing a version I uploaded several hours ago. If I open the site in an incognito window, the updated version is displayed (therefore I don't think it is actually an error in the console). I put a new version number in app.yaml I have migrated all traffic to the new version. I have cleared my cache, deleted cookies, checked my application data, everything. I even reinstalled Chrome

Register inline service worker in web app

流过昼夜 提交于 2019-12-02 07:06:43
I'm toying with adding web push notifications to a web app hosted with apps script. To do so, I need to register a service worker and I ran into an error with a cross-domain request. Raw content is hosted from *.googleusercontent.com while the script URL is script.google.com/* . I was able to successfully create an inline worker using this post on creating inline URLs created from a blob with the script. Now I'm stuck at the point of registering the worker in the browser. The following model works: HTML <!-- Display the worker status --> <div id="log"></log> Service Worker <script id="worker"

How can I claim a client when initializing a ServiceWorker to prevent having to reload the page?

岁酱吖の 提交于 2019-12-02 06:42:19
问题 I'm having trouble to wrap my head around the Clients.claim API of the ServiceWorker. From what I understand (here and here) I can call claim() on the service worker activate event to prevent having to refresh the page to initialize the ServiceWorker. I can't get it to work though and always end up having to refresh. Here's my code: Inside the service worker: self.addEventListener('install', function (event) { self.skipWaiting(); event.waitUntil(caches.open(CURRENT_CACHE_DICT.prefetch) .then

How can I claim a client when initializing a ServiceWorker to prevent having to reload the page?

筅森魡賤 提交于 2019-12-02 04:57:20
I'm having trouble to wrap my head around the Clients.claim API of the ServiceWorker. From what I understand ( here and here ) I can call claim() on the service worker activate event to prevent having to refresh the page to initialize the ServiceWorker. I can't get it to work though and always end up having to refresh. Here's my code: Inside the service worker: self.addEventListener('install', function (event) { self.skipWaiting(); event.waitUntil(caches.open(CURRENT_CACHE_DICT.prefetch) .then(function(cache) { var cachePromises = PREFETCH_URL_LIST.map(function(prefetch_url) { var url = new