-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #27 from chinmaym07/pwa
Made it PWA optimized
- Loading branch information
Showing
14 changed files
with
205 additions
and
2 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 |
---|---|---|
|
@@ -140,4 +140,6 @@ dmypy.json | |
.pytype/ | ||
|
||
# profiling data | ||
.prof | ||
.prof | ||
# Local Netlify folder | ||
.netlify |
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,9 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<browserconfig> | ||
<msapplication> | ||
<tile> | ||
<square150x150logo src="/mstile-150x150.png"/> | ||
<TileColor>#00aba9</TileColor> | ||
</tile> | ||
</msapplication> | ||
</browserconfig> |
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
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,26 @@ | ||
{ | ||
"name": "SecretPeek", | ||
"short_name": "SecretPeek", | ||
"icons": [ | ||
{ | ||
"src": "/public/android-chrome-192x192.png", | ||
"sizes": "192x192", | ||
"type": "image/png" | ||
}, | ||
{ | ||
"src": "/public/android-chrome-512x512.png", | ||
"sizes": "512x512", | ||
"type": "image/png" | ||
}, | ||
{ | ||
"src": "/public/maskable_icon.png", | ||
"sizes": "196x196", | ||
"type": "image/png", | ||
"purpose": "any maskable" | ||
} | ||
], | ||
"start_url": "/", | ||
"theme_color": "#000000", | ||
"background_color": "#ffffff", | ||
"display": "standalone" | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,75 @@ | ||
var CACHE_NAME = 'my-site-cache-v1'; | ||
const CACHE_VERSION = 2.3; | ||
|
||
const BASE_CACHE_FILES = [ | ||
'/style.css', | ||
'/script.js', | ||
'/index.html', | ||
'/manifest.json', | ||
'/public', | ||
]; | ||
const OFFLINE_CACHE_FILES = [ | ||
'/style.css', | ||
'/script.js', | ||
'/index.html', | ||
]; | ||
|
||
const MAX_TTL = { | ||
'/': 3600, | ||
html: 43200, | ||
json: 43200, | ||
js: 86400, | ||
css: 86400, | ||
}; | ||
|
||
function installServiceWorker() { | ||
return Promise.all( | ||
[caches.open(CACHE_VERSIONS.assets).then((cache) => { | ||
return cache.addAll(BASE_CACHE_FILES); | ||
} | ||
, err => console.error(`Error with ${CACHE_VERSIONS.assets}`, err)), | ||
caches.open(CACHE_VERSIONS.offline).then((cache) => { | ||
return cache.addAll(OFFLINE_CACHE_FILES); | ||
} | ||
, err => console.error(`Error with ${CACHE_VERSIONS.offline}`, err))] | ||
) | ||
.then(() => { | ||
return self.skipWaiting(); | ||
}, err => console.error("Error with installation: ", err)); | ||
} | ||
|
||
|
||
|
||
self.addEventListener('fetch', function(event) { | ||
event.respondWith( | ||
caches.match(event.request) | ||
.then(function(response) { | ||
// Cache hit - return response | ||
if (response) { | ||
return response; | ||
} | ||
|
||
return fetch(event.request).then( | ||
function(response) { | ||
// Check if we received a valid response | ||
if(!response || response.status !== 200 || response.type !== 'basic') { | ||
return response; | ||
} | ||
|
||
// IMPORTANT: Clone the response. A response is a stream | ||
// and because we want the browser to consume the response | ||
// as well as the cache consuming the response, we need | ||
// to clone it so we have two streams. | ||
var responseToCache = response.clone(); | ||
|
||
caches.open(CACHE_NAME) | ||
.then(function(cache) { | ||
cache.put(event.request, responseToCache); | ||
}); | ||
|
||
return response; | ||
} | ||
); | ||
}) | ||
); | ||
}); |