Skip to content

Instantly share code, notes, and snippets.

View steph-crown's full-sized avatar
💻
Open to work

Stephen Emmanuel steph-crown

💻
Open to work
View GitHub Profile
@steph-crown
steph-crown / sw.js
Created January 28, 2022 14:00
Fetch event of service worker
// Runs whenever there is a fetch request
self.addEventListener("fetch", (event) => {
// Checks the cache to find matching request.
// If there is a cached version of the request, it returns the cached version, otherwise it makes a new request.
event.respondWith(
caches.match(event.request).then((res) => {
return res || fetch(event.request);
})
);
});
@steph-crown
steph-crown / manifest.json
Created January 28, 2022 15:24
A web manifest file
{
"name": "Studylove PWA",
"short_name": "Studylove",
"description": "This is a PWA tutorial created by Steph Crown",
"start_url": ".",
"background_color": "#B3D1FF",
"theme_color": "#0A0F75",
"display": "standalone",
"icons": [
{