Add max-age expiration to service worker image caches

This commit is contained in:
schroda
2026-01-18 16:57:05 +01:00
parent 7b13c1dcc1
commit 7e39df09c4

View File

@@ -16,6 +16,7 @@ import legacy from '@vitejs/plugin-legacy';
import { VitePWA } from 'vite-plugin-pwa'; import { VitePWA } from 'vite-plugin-pwa';
import { lingui } from '@lingui/vite-plugin'; import { lingui } from '@lingui/vite-plugin';
import 'dotenv/config'; import 'dotenv/config';
import { d } from 'koration';
// eslint-disable-next-line import/no-default-export // eslint-disable-next-line import/no-default-export
export default defineConfig(({ command }) => ({ export default defineConfig(({ command }) => ({
@@ -70,6 +71,8 @@ export default defineConfig(({ command }) => ({
// !!! IMPORTANT !!! - Update along with ImageCache.ts // !!! IMPORTANT !!! - Update along with ImageCache.ts
cacheName: 'image-cache-chapter-pages', cacheName: 'image-cache-chapter-pages',
expiration: { expiration: {
// Max age from server
maxAgeSeconds: d(1).days.inWholeSeconds,
maxEntries: 2500, maxEntries: 2500,
purgeOnQuotaError: true, purgeOnQuotaError: true,
}, },
@@ -88,6 +91,8 @@ export default defineConfig(({ command }) => ({
// !!! IMPORTANT !!! - Update along with ImageCache.ts // !!! IMPORTANT !!! - Update along with ImageCache.ts
cacheName: 'image-cache-manga-thumbnails', cacheName: 'image-cache-manga-thumbnails',
expiration: { expiration: {
// Max age from server
maxAgeSeconds: d(1).days.inWholeSeconds,
maxEntries: 5000, maxEntries: 5000,
purgeOnQuotaError: true, purgeOnQuotaError: true,
}, },
@@ -106,6 +111,8 @@ export default defineConfig(({ command }) => ({
// !!! IMPORTANT !!! - Update along with ImageCache.ts // !!! IMPORTANT !!! - Update along with ImageCache.ts
cacheName: 'image-cache-extension-icons', cacheName: 'image-cache-extension-icons',
expiration: { expiration: {
// Max age from server
maxAgeSeconds: d(365).days.inWholeSeconds,
maxEntries: 300, maxEntries: 300,
purgeOnQuotaError: true, purgeOnQuotaError: true,
}, },
@@ -121,6 +128,7 @@ export default defineConfig(({ command }) => ({
// !!! IMPORTANT !!! - Update along with ImageCache.ts // !!! IMPORTANT !!! - Update along with ImageCache.ts
cacheName: 'image-cache-other', cacheName: 'image-cache-other',
expiration: { expiration: {
maxAgeSeconds: d(4).days.inWholeSeconds,
maxEntries: 500, maxEntries: 500,
purgeOnQuotaError: true, purgeOnQuotaError: true,
}, },