disable service worker image cache for avatars (#465)

fixes #464
This commit is contained in:
Nolan Lawson 2018-08-21 22:22:21 -07:00 committed by GitHub
parent 2956e20d18
commit d30ffc6683
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 0 additions and 23 deletions

View File

@ -1,7 +1,6 @@
const timestamp = '__timestamp__'
const ASSETS = `assets_${timestamp}`
const WEBPACK_ASSETS = `webpack_assets_${timestamp}`
const ON_DEMAND = `ondemand_${timestamp}`
// `assets` is an array of everything in the `assets` directory
const assets = __assets__
@ -36,7 +35,6 @@ self.addEventListener('activate', event => {
// delete old asset/ondemand caches
for (let key of keys) {
if (key !== ASSETS &&
key !== ON_DEMAND &&
!key.startsWith('webpack_assets_')) {
await caches.delete(key)
}
@ -63,10 +61,6 @@ self.addEventListener('activate', event => {
})())
})
const ON_DEMAND_PATHS = [
'/system/accounts/avatars'
]
self.addEventListener('fetch', event => {
const req = event.request
const url = new URL(req.url)
@ -93,23 +87,6 @@ self.addEventListener('fetch', event => {
}
}
// For these GET requests, go cache-first
if (req.method === 'GET' &&
ON_DEMAND_PATHS.some(pattern => url.pathname.startsWith(pattern))) {
let cache = await caches.open(ON_DEMAND)
let response = await cache.match(req)
if (response) {
// update asynchronously
fetch(req).then(response => {
cache.put(req, response.clone())
})
return response
}
response = await fetch(req)
cache.put(req, response.clone())
return response
}
// for everything else, go network-only
return fetch(req)
})())