mirror of
https://github.com/cheeaun/phanpy.git
synced 2025-02-16 07:11:15 +03:00
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
1 changed files with 6 additions and 1 deletions
|
@ -5,12 +5,17 @@ import { CacheFirst, StaleWhileRevalidate } from 'workbox-strategies';
|
|||
|
||||
const imageRoute = new Route(
|
||||
({ 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({
|
||||
cacheName: 'remote-images',
|
||||
plugins: [
|
||||
new ExpirationPlugin({
|
||||
maxEntries: 100,
|
||||
maxAgeSeconds: 7 * 24 * 60 * 60, // 7 days
|
||||
purgeOnQuotaError: true,
|
||||
}),
|
||||
|
|
Loading…
Add table
Reference in a new issue