Only cache avatars and emojis
No point caching all the images for a week Also they take up A LOT of space
This commit is contained in:
parent
1538400dc0
commit
bbccb8a79b
|
@ -5,12 +5,17 @@ import { CacheFirst, StaleWhileRevalidate } from 'workbox-strategies';
|
||||||
|
|
||||||
const imageRoute = new Route(
|
const imageRoute = new Route(
|
||||||
({ request, sameOrigin }) => {
|
({ request, sameOrigin }) => {
|
||||||
return !sameOrigin && request.destination === 'image';
|
const isRemote = !sameOrigin;
|
||||||
|
const isImage = request.destination === 'image';
|
||||||
|
const isAvatar = request.url.includes('/avatars/');
|
||||||
|
const isEmoji = request.url.includes('/emoji/');
|
||||||
|
return isRemote && isImage && (isAvatar || isEmoji);
|
||||||
},
|
},
|
||||||
new CacheFirst({
|
new CacheFirst({
|
||||||
cacheName: 'remote-images',
|
cacheName: 'remote-images',
|
||||||
plugins: [
|
plugins: [
|
||||||
new ExpirationPlugin({
|
new ExpirationPlugin({
|
||||||
|
maxEntries: 100,
|
||||||
maxAgeSeconds: 7 * 24 * 60 * 60, // 7 days
|
maxAgeSeconds: 7 * 24 * 60 * 60, // 7 days
|
||||||
purgeOnQuotaError: true,
|
purgeOnQuotaError: true,
|
||||||
}),
|
}),
|
||||||
|
|
Loading…
Reference in a new issue