1
0
Fork 0
mirror of https://github.com/miniflux/v2.git synced 2025-08-01 17:38:37 +00:00

Add service worker to cache feed icons

This commit is contained in:
Frédéric Guillot 2018-07-15 21:51:09 -07:00
parent c926498d3d
commit 6aa02680d8
8 changed files with 94 additions and 35 deletions

14
ui/static/js/sw.js Normal file
View file

@ -0,0 +1,14 @@
self.addEventListener("fetch", (event) => {
if (event.request.url.includes("/feed/icon/")) {
event.respondWith(
caches.open("feed_icons").then((cache) => {
return cache.match(event.request).then((response) => {
return response || fetch(event.request).then((response) => {
cache.put(event.request, response.clone());
return response;
});
});
})
);
}
});