service-worker

Cache iframe request with ServiceWorker

有些话、适合烂在心里 提交于 2019-12-24 09:36:51
问题 I'm trying to cache the request of an iframe with my ServiceWorker (using sw-toolbox.js). But no matter what I try the files are never served from the ServiceWorker as Chrome Network Tab tells me. Here is my service-worker.js: 'use strict'; importScripts('./build/sw-toolbox.js'); self.toolbox.options.cache = { name: 'ionic-cache' }; var static_urls = [ 'https://quiqqer.local/test?app=1', 'https://quiqqer.local/calendar?app=1' ]; self.toolbox.precache(static_urls); self.toolbox.router.any('/(.

Manually replaying requests queued by workbox-background-sync

微笑、不失礼 提交于 2019-12-24 09:08:04
问题 I am working on offline support in my PWA app. I am using workbox for that. This is my current code: const addToFormPlugin = new workbox.backgroundSync.Plugin('addToForm'); workbox.routing.registerRoute( RegExp('MY_PATH'), workbox.strategies.networkOnly({ plugins: [addToFormPlugin] }), 'POST' ); The code seems to works fine on my computer. However, once I run the app on the phone it takes ages to upload requests stored in IndexedDB. I know that it happens on the SYNC but it seems to take at

Service Worker in root on GAE

独自空忆成欢 提交于 2019-12-24 07:19:21
问题 I am trying to use a service worker on a basic flask app on Google App Engine for Python. From what I understand if I want the service worker to handle all requests on my domain it needs to be in the application root. However I can't figure out how to let GAE allow access to my service-worker.js in the root. I currently get a 404 response when trying to register the service worker. Any help would be much appreciated, thanks. 回答1: You can configure this via the static_files option in your app

google gcm “raw_data” payload for desktop chrome 50 beta

余生颓废 提交于 2019-12-24 01:15:31
问题 I am trying to send a and read message payload using the google GCM mechanism. To send the data I am using the instructions found under "Web Push" in: https://developers.google.com/web/updates/2016/03/web-push-encryption?hl=en where it is instructed, that until full support by chrome is available, the payload can be sent using "raw_data" which needs to be base64 encripted. to display the data I am ussing chorome 50Beta, since it is supposed to support payloads. but when the 'push' event is

Workbox is caching only time stamps to indexDb, how to intercept with json data in indexDb?

天大地大妈咪最大 提交于 2019-12-24 00:33:27
问题 Below route defines to store json data as MyCachedData in cache storage, and IndexDb only stores the url and timestamp. workboxSW.router.registerRoute('/MyApi(.*)', workboxSW.strategies.staleWhileRevalidate({ cacheName: 'MyCachedData', cacheExpiration: { maxEntries: 50 }, cacheableResponse: {statuses: [0, 200]} }) ); Is it possible to store the json data in the index db only and how can you define it to intercept (add, update, delete) using Workbox? 回答1: No, Workbox relies on the Cache

Service Worker issues

半腔热情 提交于 2019-12-23 23:50:41
问题 I'm having some issues with the service worker demo I've implemented in the page at this link. I've tried to cut the code down as much as possible for this demo, but it's too long to paste into here. One problem is that, when the page is fully loaded, and I go to the Application tab of Chrome devtools, and I see rather a lot in the Cache: It's not apparent why there is so much cached... it may be the fonts I'm loading but still... seems large. More worryingly, when I click on the Clear Site

Programmatically update service worker if update() is not available

孤人 提交于 2019-12-23 16:02:52
问题 How can I programmatically update service worker since ServiceWorkerRegistration.update() has not been implemented in Chrome yet? Is there an alternative? 回答1: I assume you got this by now but I think you want serviceWorker.skipWaiting() 回答2: Thr best workaround seems to be to force update by changing checksum of the service worker file by some simple backend code (it can be like last commented line with microtime), which will be detected by browser 回答3: From the spec. if ('serviceWorker' in

How to make ServiceWorker survive cache reset/Shift+F5?

北城以北 提交于 2019-12-23 15:09:22
问题 I want to create a website that can work even when it's server is offline — I found that that's what ServiceWorkers are for. When I reload the page with service worker and no connectivity, it works just fine. However, shift+reload (e.g. bypassing cache) disarms service worker and I get "could not connect to server" error. My question is — can I somehow prevent shift+reload (shift+f5, ctrl+f5 etc) from ruining service worker, or, at least, make it recover afterwards without restoring

Showing loader while navigating between pages - PWA

孤街醉人 提交于 2019-12-23 12:09:21
问题 I have a PHP based website. I have used service-workers and manifest.json to convert the website into a PWA . Now when I launch the PWA from my Homescreen, it works normally like an APP. But, the problem is that since PWAs does not show browser address bar, user has no way of knowing that the page is being reloaded or the next page is being loaded. When they click something next page gets loaded but no loading indicator is shown . So, now i need to add loading animation while navigating

Force reload skipping Service Worker in JavaScript

痴心易碎 提交于 2019-12-23 12:08:39
问题 Service Workers can interfere with the refresh button (by design). On desktop Chrome, you can hold shift and click the refresh button to do a hard reload, ignoring any installed ServiceWorker. Is there a way to force a reload ignoring the SW in JavaScript? (I want this so I can give mobile users a button to push if the SW starts misbehaving. Phones don't have a shift key.) 回答1: If you unregister the Service Worker before refreshing, the next page load will load without the Service Worker.