Is it possible to track geolocation with a service worker while PWA is not open

The solution is at hand and has been for some years now as this POC clearly testifies. Unfortunately W3C have fought tooth and nail to prevent it from being made available 🙁 Why? I know not. The “cui bono” argument points to plug-in vendors such as Ionic whose whole raison d’etre appears to be background … Read more

Can service workers cache POST requests?

You can’t cache POST requests using the Cache API. See https://w3c.github.io/ServiceWorker/#cache-put (point 4). There’s a related discussion in the spec repository: https://github.com/slightlyoff/ServiceWorker/issues/693 An interesting solution is the one presented in the ServiceWorker Cookbook: https://serviceworke.rs/request-deferrer.html Basically, the solution serializes requests to IndexedDB.

What is this unknown Google-originating client that triggers JavaScript errors in our PWA?

This might be a headless Chrome (probably pre-release tests, in case you have it in the Play Store), which does not feature push permission; eg. with Pupeteer, one can only override permissions, but not really accept the permission prompt… and there generally is no desktop attached, where one could push notifications to. Just try and … Read more

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

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 most specific only. Nevertheless, you can attach multiple fetch handlers and they all will process the request … Read more

Angular 5 and Service Worker: How to exclude a particular path from ngsw-config.json

Thanks to the Pedro Arantes advice, I reached the next working config (see dataGroups and “maxAge”: “0u”): { “index”: “/index.html”, “dataGroups”: [ { “name”: “api”, “urls”: [“/api”], “cacheConfig”: { “maxSize”: 0, “maxAge”: “0u”, “strategy”: “freshness” } } ], “assetGroups”: [ { “name”: “app”, “installMode”: “prefetch”, “resources”: { “files”: [ “/favicon.ico”, “/index.html” ], “versionedFiles”: [ “/*.bundle.css”, … Read more

What causes a Failed to execute ‘fetch’ on ‘ServiceWorkerGlobalScope’: ‘only-if-cached’ can be set only with ‘same-origin’ mode error?

I believe this is a Chromium bug that has been reported here. Hopefully it will be fixed soon or some more information about the issue will be published. Paul Irish implemented a temporary work around, which is as follows: if (e.request.cache === ‘only-if-cached’ && e.request.mode !== ‘same-origin’) { return; } I ran it inside the … Read more

When does code in a service worker outside of an event handler run?

In general, code that’s outside any event handler, in the “top-level” of the service worker’s global scope, will run each and every time the service worker thread(/process) is started up. The service worker thread may start (and stop) at arbitrary times, and it’s not tied to the lifetime of the web pages it controlled. (Starting/stopping … Read more

Setting service worker to exclude certain urls only

So, considering, you have not posted any code relevant to the service worker, you might consider adding a simple if conditional inside the code block for fetch This code block should already be there inside your service worker.Just add the conditionals self.addEventListener( ‘fetch’, function ( event ) { if ( event.request.url.match( ‘^.*(\/blog\/).*$’ ) ) { … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)