adding image caching

This commit is contained in:
subnub
2025-02-21 17:13:45 -05:00
parent cb6b42943e
commit a1b7f23c4b
+18 -2
View File
@@ -14,11 +14,10 @@ export default defineConfig(({ mode }) => {
plugins: [
react(),
visualizer(),
// Perhaps will be used in the future, currently lots of issues
// With downloading files on safari iOS PWA (who would have guessed)
VitePWA({
registerType: "autoUpdate",
workbox: {
globPatterns: ["**/*.{js,css,html,ico,png,svg}"],
navigateFallbackDenylist: [
/^\/file-service\/download\//, // Matches any path starting with /file-service/download/
/^\/file-service\/public\/download\/[^\/]+\/[^\/]+/, // Matches /file-service/public/download/:id/:tempToken
@@ -26,6 +25,23 @@ export default defineConfig(({ mode }) => {
/^\/file-service\/stream-video\/[^\/]+/, // Matches /file-service/stream-video/:id
/^\/file-service\/download\/[^\/]+/, // Matches /file-service/download/:id
],
runtimeCaching: [
{
// Matches any URL that follows the pattern /file-service/thumbnail/{id}
urlPattern: /\/file-service\/thumbnail\/[a-zA-Z0-9_-]+$/,
handler: "CacheFirst",
options: {
cacheName: "dynamic-thumbnails",
expiration: {
maxEntries: 100,
maxAgeSeconds: 60 * 60 * 24 * 7, // Cache for 1 week
},
cacheableResponse: {
statuses: [0, 200],
},
},
},
],
},
}),
],