service-worker

Handling authentification to Firebase Database with Fetch in a Service Worker

最后都变了- 提交于 2019-12-07 12:33:42
问题 I'm trying to query a Firebase database from a Service Worker using the Fetch API. However it doesn't work as expected as I can't get authenticated correctly. Basically what I'm trying to do is from origin https://myproject.firebaseapp.com inside a Service Worker I do a call like this : var fetchOptions = {}; fetchOptions.credentials = 'include'; var url = options.messageUrl; var request = new Request('https://myproject.firebaseio.com/user/foobar.json', fetchOptions); messagePromise = fetch

Service worker in Safari

此生再无相见时 提交于 2019-12-07 10:05:43
问题 I have a major problem with service workers, or what I think is a service worker related problem. The problem I have (only in Safari) both on Mac and iOS is that every second time I visit a route I got a 504 (Gateway Timeout) message in the console and no data is fetched from the server. Thanks in advance, Mattias 回答1: Disabling etag from server side fixed my issue. 回答2: I was having the same problem, and I was able to fix this by delaying the API call (in a component) to be executed 300

XMLHttpRequest within service worker

牧云@^-^@ 提交于 2019-12-07 09:08:39
问题 I'm trying to create a push notification system on chrome. I have a php that fetches data from mysql and echoes a JSON, now I'd like to call a function getJsonCode() that it's activated when a push notification arrives and reads the JSON data. Within my service worker I've created the standards functions. The problem is that when I create getJsonCode with a XMLHttpRequest it tells me it's not defined self.addEventListener('install', function(event) { self.skipWaiting(); console.log('Installed

Show progress while caching files using a service worker

主宰稳场 提交于 2019-12-07 06:00:59
问题 I'm not too familiar with JavaScript and have a hard time getting into service workers. I want to make a whole webapp available offline using service workers to cache the necessary files at page load. Though this is working, it takes quite some time until all the files are downloaded to disk, which makes the browser unresponsive and the user impatient. I wonder, what is the best way to show progress while the service worker is doing its magic? In the way of "Downloading file 25 of 100". How

NullInjectorError: No provider for SwUpdate! SwUpdate does not work Angular 5

强颜欢笑 提交于 2019-12-07 05:34:15
问题 Now I know there are a million posts about No Provider for such and such service, I know it needs to go in the providers please read my entire post. Basically I am trying to use SwUpdate to check to see if there is an update if so, refresh the browser: import { SwUpdate } from '@angular/service-worker'; ... export class ... constructor( private _swUp: SwUpdate ){} ngOnInit() { this.checkForUpdate(); } checkForUpdate() { if (this._swUp.isEnabled) { this._swUp.available .subscribe(() => {

Is it possible to use the new Push Notifications support in Chrome without GCM?

帅比萌擦擦* 提交于 2019-12-07 05:33:20
问题 Can I use a push service other than Google's GCM when using the new Push API with service workers? 回答1: Today, Chrome is the only browser that supports the standard push API so right now the short answer is No. A longer answer involves doing different things for different browsers Safari offers desktop notifications via APNS and a proprietary API Firefox is shipping support for push notifications soon and presumably will use a different push server than GCM. So to summarize, it seems that

Uncaught (in promise) DOMException: Registration failed - manifest empty or missing

不羁岁月 提交于 2019-12-07 04:51:03
问题 Im trying to implement push notification using Polymer. I followed this link and was able to get the service worker to be registered. I got the following comments of the Javascript console. Service Worker is ready :^) ServiceWorkerRegistration But I also received this error. Uncaught (in promise) DOMException: Registration failed - manifest empty or missing Note: <link rel="manifest" href="manifest.json"> is already in my index.html. Since Im using Google App Engine, in my app.yaml I have add

Chrome shows high cache storage use

橙三吉。 提交于 2019-12-07 03:35:42
问题 I have been analyzing the cache storage use of complex application, when I realized that the stored image or script with certain content-length N actually takes 5N-10N space in the cache storage. Consider this sample: I am requesting image from OpenStreetMap via service worker and storing it in cache. There is only one image stored in cache. The Chrome version is the latest one (Version 65.0.3325.146 (Official Build) (64-bit)). This is the view of cache storage after refresh: This is the view

Cache-first Service Worker: how to bypass cache on updated assets?

天大地大妈咪最大 提交于 2019-12-07 02:36:58
问题 Here is the scenario: You have a site that currently cached via a SW. You deploy a new version that includes an updated SW with a cache busting version. The company then announces the new features. People visit the site, however, even though the SW busts it still serves up the previous cache while updating its cache in the background. So visitors that come for the new features don't see them. Is this the expected experience with ServiceWorkers? What are the recommended strategies to get

TypeError: Failed to register a ServiceWorker: A bad HTTP response code (404) was received when fetching the script

烂漫一生 提交于 2019-12-07 00:16:45
I'm trying to add a service worker to a website.I'm using Node.js with Express.js,Vue.js and EJS.^ My node server (index.js) looks like : const https = require('https'); const fs = require('fs'); const express = require('express'); const app = express(); const router = express.Router(); const pool = require('./mysqldb.js'); const pathView = __dirname + "/views/"; var bodyParser = require("body-parser"); const listenPort = 8010; // Process application/x-www-form-urlencoded app.use(bodyParser.urlencoded({ extended: true })); // Process application/json app.use(bodyParser.json()); app.set('view