File tree Expand file tree Collapse file tree 1 file changed +19
-19
lines changed
Expand file tree Collapse file tree 1 file changed +19
-19
lines changed Original file line number Diff line number Diff line change @@ -53,6 +53,9 @@ const FILES_TO_CACHE = [
5353
5454] ;
5555
56+
57+ // add install and activate event listeners
58+
5659self . addEventListener ( 'install' , ( evt ) => {
5760
5861 self . skipWaiting ( ) ;
@@ -63,28 +66,25 @@ self.addEventListener('activate', (evt) => {
6366
6467 self . clients . claim ( ) ;
6568
66- // remove previous cached data from disk
67- evt . waitUntil (
68- caches . keys ( ) . then ( ( keyList ) => {
69- return Promise . all ( keyList . map ( ( key ) => {
70- if ( key !== WORKER_NAME ) {
71- return caches . delete ( key ) ;
72- }
73- } ) ) ;
74- } )
75- ) ;
76-
77- // precache static resources
78- evt . waitUntil (
79- caches . open ( WORKER_NAME ) . then ( ( cache ) => {
80- return cache . addAll ( FILES_TO_CACHE ) ;
81- } )
82- ) ;
83-
84- // send message to client
69+ // send install message to client
8570 workerChannel . postMessage ( {
8671 type : 'installed'
8772 } ) ;
8873
8974} ) ;
9075
76+
77+ // remove previous cached data from disk
78+ caches . keys ( ) . then ( ( keyList ) => {
79+ return Promise . all ( keyList . map ( ( key ) => {
80+ if ( key !== WORKER_NAME ) {
81+ return caches . delete ( key ) ;
82+ }
83+ } ) ) ;
84+ } ) ;
85+
86+ // precache static resources
87+ caches . open ( WORKER_NAME ) . then ( ( cache ) => {
88+ return cache . addAll ( FILES_TO_CACHE ) ;
89+ } ) ;
90+
You can’t perform that action at this time.
0 commit comments