service-worker

PWA - cached video will not play in Mobile Safari (11.4)

﹥>﹥吖頭↗ 提交于 2019-12-18 17:25:13
问题 I'm struggling to create a simple POC for iOS PWA with a small video. https://test-service-worker.azurewebsites.net/ I have simple service worker registration and I cache a small (700kB) video. When I'm online the page works just fine. When I turn on airplane mode and go offline, the page is still reloaded but video will not play. This POC is based on Google Chrome example https://googlechrome.github.io/samples/service-worker/prefetch-video/ The video from this example will not work in iOS

Register service worker in angular.js application

三世轮回 提交于 2019-12-18 16:57:23
问题 I'm creating an app using ionic and angular.js and I'm having difficulties registering a service worker which I'm intending to use to add the new app install banner feature. I'm adding the below code on my app.js file as instructed, but I'm note getting any signals of the registration happening nor any error. This is the code I'm adding to my app.js: if ('serviceWorker' in navigator) { navigator.serviceWorker.register('service-worker.js').then(function(registration) { //Registration was

Register service worker in angular.js application

自闭症网瘾萝莉.ら 提交于 2019-12-18 16:57:23
问题 I'm creating an app using ionic and angular.js and I'm having difficulties registering a service worker which I'm intending to use to add the new app install banner feature. I'm adding the below code on my app.js file as instructed, but I'm note getting any signals of the registration happening nor any error. This is the code I'm adding to my app.js: if ('serviceWorker' in navigator) { navigator.serviceWorker.register('service-worker.js').then(function(registration) { //Registration was

Firefox: Service Worker: SecurityError: DOMException: The Operation is insecure

久未见 提交于 2019-12-18 16:45:30
问题 In app.js , I am checking the serviceWorker existence in navigator object and if available then registering the SW. if ('serviceWorker' in navigator) { navigator.serviceWorker.register('./service-worker.js', { scope: './' }) .then(function(registration) { console.log("Service Worker Registered!"); }).catch(function(err) { console.log("Service Worker not registered!", err); }); } When trying to register SW, I receive the below error in Firefox. I also made sure the service-worker.js file is

How do I call a method on my ServiceWorker from within my page?

孤街醉人 提交于 2019-12-18 12:25:09
问题 I have a ServiceWorker registered on my page and want to pass some data to it so it can be stored in an IndexedDB and used later for network requests (it's an access token). Is the correct thing just to use network requests and catch them on the SW side using fetch, or is there something more clever? Note for future readers wondering similar things to me: Setting properties on the SW registration object, e.g. setting self.registration.foo to a function within the service worker and doing the

Service Workers unavailable in WKWebView in iOS 11.3

假如想象 提交于 2019-12-18 12:23:37
问题 Service Workers were available in WKWebView in iOS 11.3 betas, but do not appear to be available in the final GM version of iOS 11.3. Does anyone know how to re-enable Service Workers in WKWebView on iOS? 回答1: Service Workers in WKWebView now require an entitlement: com.apple.developer.WebKit.ServiceWorkers , which should be added to the .entitlements plist as a Boolean with a value of YES . Currently this will only work in the iOS Simulator, until such time as Apple update the Apple

Application Cache or Service Workers - which to use in 2016/Q2?

孤人 提交于 2019-12-18 10:50:14
问题 Quick question for discussion really, as I wanted to have input from different people. I am in the process of developing a web page app that must be available offline. Now to do this, as I understand it, you would go about using either the application caching feature or by using service workers. However, here is the conundrum I have. When researching the application cache, the MDN clearly states: Deprecated: This feature has been removed from the Web standards. Though some browsers may still

Service-worker force update of new assets

和自甴很熟 提交于 2019-12-18 10:33:15
问题 I've been reading through the html5rocks Introduction to service worker article and have created a basic service worker that caches the page, JS and CSS which works as expected: var CACHE_NAME = 'my-site-cache-v1'; var urlsToCache = [ '/' ]; // Set the callback for the install step self.addEventListener('install', function (event) { // Perform install steps event.waitUntil( caches.open(CACHE_NAME) .then(function(cache) { console.log('Opened cache'); return cache.addAll(urlsToCache); }) ); });

Service-worker force update of new assets

孤人 提交于 2019-12-18 10:32:59
问题 I've been reading through the html5rocks Introduction to service worker article and have created a basic service worker that caches the page, JS and CSS which works as expected: var CACHE_NAME = 'my-site-cache-v1'; var urlsToCache = [ '/' ]; // Set the callback for the install step self.addEventListener('install', function (event) { // Perform install steps event.waitUntil( caches.open(CACHE_NAME) .then(function(cache) { console.log('Opened cache'); return cache.addAll(urlsToCache); }) ); });

Structuring a TypeScript project with workers

ぃ、小莉子 提交于 2019-12-18 10:11:13
问题 How should I structure a project that includes main thread (DOM) script, and workers? Eg: main.ts // This file must have DOM types, but not worker types. const worker = new Worker('worker.js'); worker.onmessage = (event) => { // Ideally, I should be able to reference types from the worker: const data = event.data as import('./worker').HelloMessage; console.log(data.hello); }; worker.ts // This file must have worker types, but not DOM types. // The global object must be one of the worker