-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7fcf347
commit 8261cf6
Showing
2 changed files
with
40 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
{ | ||
"short_name": "Portfolio", | ||
"name": "My PWA Portfolio", | ||
"icons": [ | ||
{ | ||
"src": "assets/images/logo.png", | ||
"type": "image/png", | ||
"sizes": "192x192" | ||
}, | ||
{ | ||
"src": "assets/images/logo.png", | ||
"type": "image/png", | ||
"sizes": "512x512" | ||
} | ||
], | ||
"start_url": "/index.html", | ||
"background_color": "#000000", | ||
"display": "standalone", | ||
"theme_color": "#ff0000" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
// On install - caching the application shell | ||
self.addEventListener('install', function(event) { | ||
event.waitUntil( | ||
caches.open('sw-cache').then(function(cache) { | ||
// cache any static files that make up the application shell | ||
return cache.add('index.html'); | ||
}) | ||
); | ||
}); | ||
|
||
// On network request | ||
self.addEventListener('fetch', function(event) { | ||
event.respondWith( | ||
// Try the cache | ||
caches.match(event.request).then(function(response) { | ||
//If response found return it, else fetch again | ||
return response || fetch(event.request); | ||
}) | ||
); | ||
}); |