workbox

How to make workbox cache cross origin responses?

随声附和 提交于 2019-12-11 08:07:25
问题 According to workbox doc, cross domain request should be configured to ensure that regular expression matches the beginning of the URL. However, it doesn't work. The service worker code is like below. importScripts('https://storage.googleapis.com/workbox-cdn/releases/3.0.0/workbox-sw.js'); workbox.routing.registerRoute( /.*\.(png|jpg|jpeg|svg|gif)/, workbox.strategies.cacheFirst() ); workbox.routing.registerRoute( new RegExp('^https://a248.e.akamai.net/.*'), workbox.strategies.cacheFirst() );

notificationclick event service worker

孤街醉人 提交于 2019-12-11 03:42:23
问题 I'm working with service worker to display notification between my users. In my code I include notificationclick event. With this event I'm trying to manage two cases. First case, if in my browser the page of my site is opening, don't open it but focus on it. Second case, if my browser don't show my site, open it and focus on it. But I haven't been succed... Here is my current code: self.addEventListener('notificationclick', function (e) { console.log('notification was clicked') var

Workbox's precache manifest file contains invalid URL strings in Laravel Mix setting

懵懂的女人 提交于 2019-12-11 01:56:54
问题 I'm using Workbox 3.0 (webpack-plugin) and Laravel Mix (5.6) to auto-generate a ServiceWorker file. When running the webpack compiler, the manifest file generated by Workbox for pre-cached assets looks like this: self.__precacheManifest = [ { "revision": "89c25ce71806a695a25e", "url": "//js/app.js" }, { "revision": "89c25ce71806a695a25e", "url": "//css/app.css" } ]; Obviously, the URL strings are wrong and cause errors on the actual web page. Here is my webpack.mix.js : (relevant parts) const

Read env variable from service worker file using workbox

感情迁移 提交于 2019-12-10 14:46:52
问题 I'm working with workbox-sw and workbox-webpack-plugin My src sw.js file at root folder (same level with my .env file) How can I get env variables and accessing it into my src sw.js file This is from my webpack.config.js new workboxPlugin({ globDirectory: 'dist', globPatterns: ['**/*.{html,js,css,svg,otf,png,jpg,gif}'], swSrc: './sw.js', swDest: path.join('public', 'sw.js') }) Every help will be appreciated! Thanks everyone! 回答1: Because you're using swSrc: './sw.js' , that implies that the .

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

孤街浪徒 提交于 2019-12-08 07:22:49
问题 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

Workbox pre-cached audio with range requests router fails to play in Chrome when served from Firebase

此生再无相见时 提交于 2019-12-08 05:00:28
问题 Background I have created a PWA test project to find out how to get audio caching working with Workbox, including scrub/seek using the range requests plugin. I want the app to precache all audio and for this audio to be playable offline, including scrub/seek. Pre-caching the audio can be done in one of two ways: Using Workbox injectManifest. By manually adding audio files to a cache using cache.add(URL) But audio files cached with the first method (injectManifest) will not scrub/seek because

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 = [

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

Clear Workbox cache of all content

好久不见. 提交于 2019-12-07 08:34:01
问题 Using Workbox in a service worker in a javascript webapp. Want to clear the entire workbox/application cache of all content... basically go back to a state as similar as possible to the state before first load of the app into a browser, potentially to be followed by refreshing via window.location.href = '/'. Googling and looking on SO, I have found various recipes for clearing various things from the cache. I have not been able to figure out a simple way to just 'clear everything and start