service-worker

Angular: fully install service worker before anything else

点点圈 提交于 2019-12-08 03:59:40
问题 I'm writing a PWA in Angular that needs to be ready to go offline from a single page load. The documentation for the service worker life cycle specifies that the worker is installed but not active immediately: https://developers.google.com/web/fundamentals/primers/service-workers/lifecycle This is by design and can be overruled by calling clients.claim() . The problem with this is that Angular loads the service worker after the whole app has been loaded so claim() has nothing left to claim.

ServiceWorker fails on hard reload (Ctrl-Shift-R) in Chrome

早过忘川 提交于 2019-12-08 03:47:16
问题 Why does service worker fail after a hard reload (Ctrl-Shift-R)? ---- case 1 CHROME --- success Uninstall service worker Load page Page installs service worker Worker.postMessage() succeeds reload page Worker.postMessage() succeeds ---- case 2 CHROME --- failure Uninstall service worker Load page Page installs service worker Worker.postMessage() succeeds HARD RELOAD (ctrl-shift-R) page (serviceworker still running according to chrome://serviceworker-internals/ ) Worker.postMessage() fails --

Requests through service-worker are done twice

老子叫甜甜 提交于 2019-12-08 02:20:04
问题 I've done a simple service-worker to defer requests that fail for my JS application (following this example) and it works well. But I still have a problem when requests succeed: the requests are done twice. One time normaly and one time by the service-worker due to the fetch() call I guess. It's a real problem because when the client want to save datas, they are saved twice... Here is the code : const queue = new workbox.backgroundSync.Queue('deferredRequestsQueue'); const requestsToDefer = [

How do I create a simple service worker to add new items to cache offline?

匆匆过客 提交于 2019-12-07 21:57:03
问题 I am wanting to take the response from a simple API, use it to create a series of URLs (an array), that I then want to feed to a service worker, and have it add each entry to the offline storage. For background, I have some limited experience with sw-precache (sw-precache-webpack-plugin), sw-toolbox, and JavaScript in general, though that is changing. Currently have a webpack + vue setup getting data from a simple API I built a long time ago. A user who visits my site likely wants to have one

How to use window.caches to save pages from window object?

…衆ロ難τιáo~ 提交于 2019-12-07 20:46:47
问题 Most examples of saving an 'app shell' show the process from a service worker. However I noticed that you can also access the caches object from the window. So my question is, can I save pages for offline from the a page itself, and if so, what is the point of a service worker if this is possible? 回答1: There's a chicken-and-the-egg problem here: while your web pages can read from and write to the same caches that a service worker has access to, via window.caches , you need a service worker to

service worker does my web slower! , how to add offline capabilities to Django work using workbox

梦想与她 提交于 2019-12-07 17:55:30
I have been trying since some days to give offline capabilities using workbox to my Django Web App without success. I have follow the get started guide and I manage to register with succeed the service worker and to save/serve from cache the the static and media resources. Code done to archive the describe: urls.py ... url(r'^service-worker.js', cache_control(max_age=60*60*24)(TemplateView.as_view( template_name="sw.js", content_type='application/javascript', )), name='sw.js'), ... base.html template ... <!-- bottom of body --> <script> // Check that service workers are registered if (

React w/ Service Worker & Push Notifications

五迷三道 提交于 2019-12-07 15:48:43
问题 Some initial considerations: "react": "^16.8.2", "react-scripts": "2.1.5" I have created a new react app and I need to implement Push Notifications. Following this tutorial, I was able to get up and running in 5 minutes, but now I have to implement the same strategy (kinda) into a react app. The problem I am facing is that I am able to subscribe to the Notification API, but I'm not sure how to edit the service-worker.js file to add an event listener to catch the push event ( Handle a Push

serviceworker is it possible to add headers to url request

拈花ヽ惹草 提交于 2019-12-07 15:26:26
问题 I have a website which I don't want to make people create accounts. It is a news feed with each news article categorized. I want to allow people to tag the categories they are interested in so that next time they go to the site it only shows news for the categories that are tagged. I'm saving the tags in an indexedDB which I understand is available in a service worker. Hence in my service worker I want to "intercept" requests to www.my-url.com , check the indexDB for what categories this

Angular 6 PWA service worker not serving content offline

妖精的绣舞 提交于 2019-12-07 14:11:55
问题 I'm trying to set up a PWA with Angular 6 and having trouble to make the service worker serve content offline. I tried a lot of configurations and stuff for a couple of days now but with no success. The service worker seems to be registered and running lighthouse in audits tab in Chrome passes the pwa test. I'm using Contentful to serve texts/assets for this site. Service worker is fetching the content from dataGroups but it returns a 204 code when the service worker is doing the fetching. I

Chrome dev tools showing high cache storage utilisation

徘徊边缘 提交于 2019-12-07 13:04:28
问题 I was analyzing the service workers and cache storage we have implemented in our website. Going through the process, I found out that the amount of cache storage used by the website is huge. The cumulative size of the files that I am adding to cache storage is not more than 5-6 MB . But in the chrome dev tools, it shows approximately 130 MB storage used. chrome - v 63 . OS - osx In incognito mode it shows usage as high as 100 MB which causes Quota Exceeded error . Even after clearing browsing