File tree Expand file tree Collapse file tree 1 file changed +16
-11
lines changed Expand file tree Collapse file tree 1 file changed +16
-11
lines changed Original file line number Diff line number Diff line change @@ -57,17 +57,22 @@ function fromCache(request) {
57
57
// Update consists in opening the cache, performing a network request and
58
58
// storing the new response data.
59
59
function update ( request ) {
60
- return caches . open ( CACHE ) . then ( function ( cache ) {
61
- return fetch ( request ) . then ( function ( response ) {
62
- return cache . put ( request , response ) ;
63
- } ) . catch ( function ( error ) {
64
- console . log ( error ) ;
65
- //do nothing
66
- return new Promise ( function ( resolve , reject ) {
67
- resolve ( ) ;
68
- } ) ;
69
- } ) ;
70
- } ) ;
60
+ if ( navigator . onLine ) {
61
+ return caches . open ( CACHE ) . then ( function ( cache ) {
62
+ return fetch ( request ) . then ( function ( response ) {
63
+ return cache . put ( request , response ) ;
64
+ } ) . catch ( function ( error ) {
65
+ console . log ( error ) ;
66
+ //do nothing
67
+ return new Promise ( function ( resolve , reject ) {
68
+ resolve ( ) ;
69
+ } ) ;
70
+ } ) ;
71
+ } ) ;
72
+ }
73
+ return new Promise ( function ( resolve , reject ) {
74
+ resolve ( ) ;
75
+ } ) ;
71
76
}
72
77
73
78
function doNotCache ( request ) {
You can’t perform that action at this time.
0 commit comments