service-worker

302 redirects do not work in a service worker built with Google Workbox

被刻印的时光 ゝ 提交于 2020-01-04 05:45:08
问题 For having the "add tome homescreen" alert displayed, I want to integrate a service-worker and an offline capability of the application: When the user is offline, the app should simply display a special offline HTML file. My service-worker looks like this: importScripts('https://storage.googleapis.com/workbox-cdn/releases/3.1.0/workbox-sw.js'); const CACHE_VERSION = 1; workbox.core.setCacheNameDetails({ prefix: 'app', suffix: 'v' + CACHE_VERSION }); workbox.routing.registerRoute( '/offline

understanding fetch in js

这一生的挚爱 提交于 2020-01-04 05:34:14
问题 I checked out a few resources but don't really get the fetch method. What is the point in having 2 then -s? What is the first and the second then good for? Why is a return in the first one? fetch('http://some-site.com/cors-enabled/some.json') .then(function(response) { return response.text(); }) .then(function(text) { console.log('Request successful', text); }) .catch(function(error) { log('Request failed', error) }); 回答1: For a much detailed answer please follow the documentation links fetch

How exactly add “Service-Worker-Allowed” to register service worker scope in upper folder

大城市里の小女人 提交于 2020-01-03 11:45:49
问题 There are similar questions about it, but it's not very clear how to apply the solution, and keep to receive an error. I explain. I'd like to create a simply html/js app using service worker technology. I have: Index.html js/app.js js/sw.js in app.js the code is (see //*** comments to clearify): // *** I receive always the error: // *** ERROR: The path of the provided scope ('/') is not under the max scope allowed ('/js/'). // *** Adjust the scope, move the Service Worker script, or use the

How exactly add “Service-Worker-Allowed” to register service worker scope in upper folder

╄→尐↘猪︶ㄣ 提交于 2020-01-03 11:45:10
问题 There are similar questions about it, but it's not very clear how to apply the solution, and keep to receive an error. I explain. I'd like to create a simply html/js app using service worker technology. I have: Index.html js/app.js js/sw.js in app.js the code is (see //*** comments to clearify): // *** I receive always the error: // *** ERROR: The path of the provided scope ('/') is not under the max scope allowed ('/js/'). // *** Adjust the scope, move the Service Worker script, or use the

Service Worker fetch request from cache so page is not getting updated from new data

旧时模样 提交于 2020-01-03 05:03:11
问题 I am trying to implement the service worker in my AngularJS project for the purpose that if the server(nginx in my case) is restarted then offline page must be displayed for that period but I stuck in the other case. I have a page where I list the items using GET request, it's fetching response from the server (for the 1 st time), response data being stored in cache BUT my page is updating within regular interval so using this technique the new data are not displaying immediately. What is

ServiceWorker fails to fetch external resource without reason

假如想象 提交于 2020-01-03 03:04:34
问题 I'm trying to fetch and cache some external resources/websites using a service worker. My code in service-worker.js is the following: 'use strict'; var static_urls = [ 'https://quiqqer.local/test?app=1', 'https://quiqqer.local/calendar?app=1' ]; self.addEventListener('install', function (event) { event.waitUntil( caches.open('ionic-cache').then(function(cache) { cache.addAll(static_urls.map(function (urlToPrefetch) { console.log(urlToPrefetch); return new Request(urlToPrefetch, {mode: 'no

Why do service workers only work over HTTPS?

[亡魂溺海] 提交于 2020-01-02 06:37:06
问题 Per the original proposal, regarding "Prefer Secure Origins For Powerful New Features" “Particularly powerful” would mean things like: features that handle personally-identifiable information, features that handle high-value information like credentials or payment instruments, features that provide the origin with control over the UA's trustworthy/native UI, access to sensors on the user's device, or generally any feature that we would provide a user-settable permission or privilege to.

Service Worker support in chrome webview

删除回忆录丶 提交于 2020-01-02 01:16:15
问题 Is Service Worker supported in chrome webview for android, if yes then from which version is it supported. Tried googling, but didn't find proper information. 回答1: As per this announcement, service workers have been supported in Chrome WebViews since March of 2015 (Android WebView v40+). Devices running Android OS 5.0 and higher should have it. Since WebViews have their own sandboxed environment, the data cached by a service worker there won't be exposed to the normal Chrome application, and

Can I use Add to home screen in Chrome on an iOS device?

点点圈 提交于 2020-01-01 07:29:17
问题 I know I can use Chrome on a desktop or Android device to “Add to Home screen”. I know I can use “Add to homes screen” in Safari iOS. But, can I use “Add to home screen” feature in Chrome for iOS? Thanks, Wayne 回答1: No. There is no such option in Chrome for iOS. I'm using iOS 12 on iPhone X with latest Chrome and I don't see such option. Safari for iOS have "Add to home screen" for a long time now. Its just the "Service worker" support that came recently in 11.3 version . Notably, Chrome for

Request headers not sent from Service Worker

邮差的信 提交于 2020-01-01 05:18:12
问题 I'm trying to fetch a web service from a Service Worker. This service is a JSP secured with basic Apache authentication, so I must provide the credentials to authenticate in the request headers. The following request works just fine from the main window: self.addEventListener('push', function(event) { console.log('Received a push message', event); event.waitUntil( fetch(ONLINE_SITE_ENDPOINT, { method: 'GET', mode: 'cors', headers: { 'Accept': 'application/json', 'Authorization': 'Basic btoa