Skip to content

Commit

Permalink
request network first instead of cache ✔
Browse files Browse the repository at this point in the history
  • Loading branch information
murtuzaalisurti committed May 8, 2022
1 parent aac29fc commit ef5bc8b
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions serviceWorker.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,18 @@ self.addEventListener("install", installEvent => {

self.addEventListener("fetch", fetchEvent => {
fetchEvent.respondWith(
caches.match(fetchEvent.request).then(res => {
return res || fetch(fetchEvent.request)

// network request first instead of cache
fetch(fetchEvent.request).catch(function() {
return caches.match(fetchEvent.request)
})

/*------------------------------------------*/

// cache first instead of network request

/* caches.match(fetchEvent.request).then(res => {
return res || fetch(fetchEvent.request)
}) */
)
})

1 comment on commit ef5bc8b

@vercel
Copy link

@vercel vercel bot commented on ef5bc8b May 8, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

qr – ./

qr-git-master-murtuzaalisurti.vercel.app
qr-codes.vercel.app
qr-murtuzaalisurti.vercel.app

Please sign in to comment.