showing results for - "service worker js"
Sara
19 Jul 2018
1/*
2 Copyright 2016 Google Inc. All Rights Reserved.
3 Licensed under the Apache License, Version 2.0 (the "License");
4 you may not use this file except in compliance with the License.
5 You may obtain a copy of the License at
6 http://www.apache.org/licenses/LICENSE-2.0
7 Unless required by applicable law or agreed to in writing, software
8 distributed under the License is distributed on an "AS IS" BASIS,
9 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10 See the License for the specific language governing permissions and
11 limitations under the License.
12 */
13
14// Names of the two caches used in this version of the service worker.
15// Change to v2, etc. when you update any of the local resources, which will
16// in turn trigger the install event again.
17const PRECACHE = 'precache-v1';
18const RUNTIME = 'runtime';
19
20// A list of local resources we always want to be cached.
21const PRECACHE_URLS = [
22  'index.html',
23  './', // Alias for index.html
24  'styles.css',
25  '../../styles/main.css',
26  'demo.js'
27];
28
29// The install handler takes care of precaching the resources we always need.
30self.addEventListener('install', event => {
31  event.waitUntil(
32    caches.open(PRECACHE)
33      .then(cache => cache.addAll(PRECACHE_URLS))
34      .then(self.skipWaiting())
35  );
36});
37
38// The activate handler takes care of cleaning up old caches.
39self.addEventListener('activate', event => {
40  const currentCaches = [PRECACHE, RUNTIME];
41  event.waitUntil(
42    caches.keys().then(cacheNames => {
43      return cacheNames.filter(cacheName => !currentCaches.includes(cacheName));
44    }).then(cachesToDelete => {
45      return Promise.all(cachesToDelete.map(cacheToDelete => {
46        return caches.delete(cacheToDelete);
47      }));
48    }).then(() => self.clients.claim())
49  );
50});
51
52// The fetch handler serves responses for same-origin resources from a cache.
53// If no response is found, it populates the runtime cache with the response
54// from the network before returning it to the page.
55self.addEventListener('fetch', event => {
56  // Skip cross-origin requests, like those for Google Analytics.
57  if (event.request.url.startsWith(self.location.origin)) {
58    event.respondWith(
59      caches.match(event.request).then(cachedResponse => {
60        if (cachedResponse) {
61          return cachedResponse;
62        }
63
64        return caches.open(RUNTIME).then(cache => {
65          return fetch(event.request).then(response => {
66            // Put a copy of the response in the runtime cache.
67            return cache.put(event.request, response.clone()).then(() => {
68              return response;
69            });
70          });
71        });
72      })
73    );
74  }
75});
Anna
15 Sep 2019
1if ('serviceWorker' in navigator) {  window.addEventListener('load', function() {    navigator.serviceWorker.register('/sw.js').then(function(registration) {      // Registration was successful      console.log('ServiceWorker registration successful with scope: ', registration.scope);    }, function(err) {      // registration failed :(      console.log('ServiceWorker registration failed: ', err);    });  });}
queries leading to this page
how service worker jsjavascript register service workerserviceworker jsservice workers in jswhat are worker servicesservice worker javascriptwho are considered service worker examplewhat is servive workerusing service workershow to install service worker in javascriptjavascript service workersservice worker filegood service worker exampleservice worker 7ehow to set up a service worker on an html pageget service worker jsshould serveice worker be started in html fileservices worker in javsdcriptjavascript get a service workerservice worker jsuse service worker in nodejsservice worker script service worker js 27 29service worker to a web applicationservice worker on server do i need a service worker 3fjavascript workernode js service workerjavascript create service workera service workerexample of web site with service workerservice worker nedircalling an endpoint on the service workerservice worker call javascript functionservice workers are not enabled chromepossible to serve js file from service worker when onlinejavascript service worker in js fileservice worker in onlineserviceworker javascriptservice worker events to pagereinstall service workerwhat is service worker jshow to service workerpush technoly service workerscalling a get endpoint on the service workerservuice workerregistert service workerservice worker usedservice worker libraryhow to host a service worker at the root of your website expressjsuse a service workerserviceworker webwhat are worker servicehow to call service worker in jsjavascript service worker libraryis service worker boilerplatejavascript service worker templateservice worker details jsserviceworker fileservice worker see events in pagehow to make a service workerwhat is servudeworker jswhat is a service worker in programmingservice worker in html5service worker objectservice worker jsservice worker exampleservice workers appcache tutorialwhat is service workersuse of service worker in web applicationservice worker for what they are usedwebsite service workerwhat is a js service workerjavascript api to check if your getting a phonecall for pwathis in service worker javascript service worker on web applicationsw jsservice worker nodejsservice worker example websitesi deleted service worker js filewrite a service worker javascript service workerservice worker in javascriptwhat is service worker used forcan i use service workerservice worker briefly describe the technologies used service worker fetch examplehwy use service workerjavascript example service workercreating js service workerservice worker javascript w3schoolsservice worker reatsw jsservice workerwhy use service workerservice worker cache save credentials service worker languagehow service worker working on server web service workera backend service workercreating service workerserviceworkers jsservice worker docsservice workers 3a an introductionjquery service workerservice worker js c 23 examplejs start service workerserviceworker js introsevice workerservice worker example filegenerate service worker using javascript 28from serviceworker 29service worker javascriptdigital scroe service workersimple service worker exampleservice worker for which browsersservice worker fetch in installwhat is serviceworkers in nodejsservice worker state java scriptwhat is a service worker used for 27this 27 in service workerreasons for service workerwhats a service worker jsservice workers in javascriptservice worker example usageservice worker thisservice worker js downloadservice worker web workerservie workerservice worker installservice handler javscripyservice worker in jswho made service workerexamples of service workersservice workers frontend or backend 3fservice worker css game solutionservice worker js example filelocalhost 3aservice worker jsworker service examplewhat does service worker doservice worker basicnodejs service workerservice workers jsgood service worker code examplehow to write a service worker in javascript 5cservice worker jsjs create service workerwhats a service workerdefine service worker js js service worker exampleworker service tutorialservice worker nodeexample service worker jsservice worker js wikiservice workersservice worker scriptwhat is a service worker webwhat does the service worker do 3fservice worker can i usewhich statments are true about serviceworkercreate service worker jschrome served from serviceworkerserver worker fileservice worker node js 22this 22 in service workernode js service worker exampleget installed service worker versionserver workershow to host a service worker at the root of your websiteservice worker insttall time caceservice workers tutorialservice worker optionsservice worker javascript exampleservice worker javascript tutorialwhat is a service worker codehow to install service worker in wordservice worker js in pwaservice worker report ststuswhere is my service workerservice workerrhow to write a service workerworker service databaseservice worker sw jshow does service worker called in html5how to use service workeruse service worker in javascriptuser credentials service workerway to create a service worker neatly jswhat is the use of worker serviceservice worker in browseropen service worker page in chromehow to detecte mobile device on service worderservice worker js on httpwhat is the service worker and web workersimple background service worker javascriptservice worker example 23 in url in service workerexplain service workerregisterworker jsservice workers implement appcache event model 28from service worker 29 node jscustom service worker jssimple service worker for pwaonline first service wokrewhat is a service worker javascriptservice worker backgroun processservice worker htmlserviceworker js addchrome version support service workerin app browser service workerjs fetch in service workerwhat are web worker and service workerdownload service worker js 5dservice worker detemine if downloadingcreate service worker js filecreate a basic service worker in jsjavascript web workerservice worker with phtmlservice worker js exampledoes the service worker go into source controlweb worker service workerjavascript service workeruse service workerlocal service worker for javascriptwhy do i have rportwebvitals instead of service workerdoes start ul in service worker have to have slash infrontservice workerrswhat does service workers mean in developmenthow to register service worker in jsadvanced service worker demoscreate service worker javascriptjsdom service workerservice worker jswhat a service worker can doservice worketrcache manager service workerjs code for service worker why service workerget 2fservice worker jswhat can i do in service workerservice worker examplesservice worker script examplewhat is a service worker 3fonline example of web site with service workerservice worker w3chow to register a service worker javascripthow to make service worker jsservice worker jspower web application service worker not working when back onlineuse of service workerjavascript execute code in service workerwindow addeventlistener or document addeventlistener service workerservice worker based websiteservice workers explainedhow to create a service workerintroduction to service workersopen service worker from other sitesserviceworker jsuse of service worker javascriptcan we write service worker tag in js filewhat 27s a worker serviceservice worker web apigood service workerwhat is a service worker jsservices workermake service worker in javascript google photo service workerservie worker jsservice worker code exampleo 09serviceworker jshow to use service worker on localhostbasic service workerservice workeswhat is worker service node jsworker servicehow can i use service workerserver worker simple filescript service workerservice worker jhow to write service worker jsservice worker c3 a9 um web workercheck service worker is loading in chromeworker service node jsservice workers nodejsmethods in service workerservice worker for static siteweb worker and service workerservice worker hswhen to use service workershow to install serviceworker javajavbascript get a service workerhow to generate service worker for my appcan i use the service workerinstall server workerhow to develop service worker javascriptservice worker report cache statuscheck is service workerserviceworker js or reportwebvital jsservice worker js what is itexample web site with service workeri don 27t have the service worker file in reactservice workers chromebasic service worker tutorialservice worker on server sideserviceworker js hiding codeservice worker new workerservice worker cache save passwordhow to create a service worker in nodeservice worker how towhat can i do with service workerservice worker js file downloadservice worker html5 tutorialwhat are worker and service workerjs service worker start serviceservice worker starter code jshow does service worker workswhat is service workerwhat is service worker in jswhat are service workerservice worker js examplejs service workersservice worker download filewhere can i install the servicewroker js filequ 27est ce que service worker in react 23628 services worker javascriptinistallation code for service workerdownload service worker jshow to add service worker jswhat is a service worker in javascriptservice worker webwhat is use of service workerservice worker js pwahow service worker worksservice worker code sampleservice worker templatesimple example on service workerconnecting serviceworker with serverwhat is a worker servicesample service worker jshow service worker works with httpsample service worker jscreating a service worker javascriptwhat is service worker and web workerservice worker and web workerwhat is a service workergood service worker codepwa service workerhow does a service with worker nodes workcreate react app service workerservice worker js pwawhat does a service worker dohtml service worker 7e javascript service workerswhere to find servise worker js fileexample service worker jsinstall service workerrun serveice workergoogle drive service workerwebsites using service workershow many service workers can have jsservice worker domcomplete service worker exampleservice worker on installwhat is a net worker servicewhere to put service workerwhats service workerservice worker pass datta to new tabservice worker min jsis report webvitals and service worker js sameservice worker js tutorialcreate a service worker javascriptfrom service workerjavascript serviceservice workers examplesservice worker definitionjs service worker tutorialjs worker 2fservice worker jshow to write a script to enable on and off service workerservice workers javascriptservice worker in chromeservice worker code to install on androidservice worker enquire status track installing in service workerwhat is service worker jsmobile service workerchrome extension service worker exampleserviceworker scopeservice worker guide service worker js makehow to check service worker is added ornotwhat is service worker and how its workchrome not fetching service workerservice worker 25where is service worker jswhare to find service worker jsgoogle search console serviceworkerwhen should we use service worker what is service worker jsservice worker codeservice worker in htmlservice worker explain about service workerservice worker weservice worker apijavascript add service workersimple service worker codeservice worker what isservice worker applicationhow to create service workerwhat does service worker do in javascripthow to use a service workerjavascript service worker exampleservice worker tutorialwhat is service worker in javascriptsimple service workeris register service worker neededjss service workerservice worker chrome red crosslink to service worker htmljs service workeraccess html from service workerwhat are service workersservice worker js documeservice worker see events in uiservice worker sample coderegister service worker javascriptwhat service worker can dohow to use service workerswhat can we do with service workerservice worker in an application do whatservice worker example javascripthow to create a service worker in javascripthow to add service workeradd service worker javascriptwhat is service workerwebsites that use service workersbasics of service workersservice worker meansservice worker in node jsfull code for an service workerrestore serviceworker js fileserviceworker installwhat is a service worker in jsservice worker js