File tree Expand file tree Collapse file tree 1 file changed +17
-28
lines changed
Expand file tree Collapse file tree 1 file changed +17
-28
lines changed Original file line number Diff line number Diff line change @@ -59,38 +59,27 @@ const FILES_TO_CACHE = [
5959
6060] ;
6161
62+
63+ // remove previous cached data
64+ caches . keys ( ) . then ( ( keyList ) => {
65+ return Promise . all ( keyList . map ( ( key ) => {
66+ if ( key !== WORKER_NAME ) {
67+ return caches . delete ( key ) ;
68+ }
69+ } ) ) ;
70+ } ) ;
71+
72+ // precache static resources
73+ caches . open ( WORKER_NAME ) . then ( ( cache ) => {
74+ return cache . addAll ( FILES_TO_CACHE ) ;
75+ } ) ;
76+
77+
6278self . addEventListener ( 'install' , ( evt ) => {
63-
6479 self . skipWaiting ( ) ;
65-
6680} ) ;
6781
6882self . addEventListener ( 'activate' , ( evt ) => {
69-
70- self . clients . claim ( ) ;
71-
72- // remove previous cached data from disk
73- evt . waitUntil (
74- caches . keys ( ) . then ( ( keyList ) => {
75- return Promise . all ( keyList . map ( ( key ) => {
76- if ( key !== WORKER_NAME ) {
77- return caches . delete ( key ) ;
78- }
79- } ) ) ;
80- } )
81- ) ;
82-
83- // precache static resources
84- evt . waitUntil (
85- caches . open ( WORKER_NAME ) . then ( ( cache ) => {
86- return cache . addAll ( FILES_TO_CACHE ) ;
87- } )
88- ) ;
89-
90- // send reload request to client
91- /*workerChannel.postMessage({
92- type: 'reload'
93- });*/
94-
83+ self . clients . claim ( ) ;
9584} ) ;
9685
You can’t perform that action at this time.
0 commit comments