Aditya DN commited on
Commit
f52d067
·
verified ·
1 Parent(s): d2a3156

Update vite.config.ts

Browse files
Files changed (1) hide show
  1. vite.config.ts +28 -1
vite.config.ts CHANGED
@@ -39,9 +39,36 @@ export default defineConfig(({ mode }) => {
39
  ],
40
  },
41
  workbox: {
42
- globPatterns: ['**/*.{js,css,html,ico,png,mp3}', `${videosPath}/*.mp4`],
43
  maximumFileSizeToCacheInBytes: 512 * 1024 * 1024,
44
  },
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
45
  }),
46
  ],
47
  define: {
 
39
  ],
40
  },
41
  workbox: {
42
+ globPatterns: ['**/*.{js,css,html,ico,png,mp3}'],
43
  maximumFileSizeToCacheInBytes: 512 * 1024 * 1024,
44
  },
45
+ runtimeCaching: [
46
+ {
47
+ // Cocokkan semua permintaan yang berakhiran .mp4
48
+ urlPattern: ({ url }) => url.pathname.endsWith('.mp4'),
49
+
50
+ // Terapkan strategi CacheFirst
51
+ // Artinya: Cek cache dulu. Jika ada, sajikan dari cache.
52
+ // Jika tidak, ambil dari jaringan, sajikan, DAN SIMPAN ke cache.
53
+ handler: 'CacheFirst',
54
+
55
+ options: {
56
+ // Buat nama cache khusus untuk video
57
+ cacheName: 'video-cache',
58
+
59
+ // Konfigurasi penting untuk mencegah cache membengkak
60
+ expiration: {
61
+ maxEntries: 100, // Simpan maksimal 100 video
62
+ maxAgeSeconds: 60 * 60 * 24 * 30, // Simpan video selama 30 hari
63
+ },
64
+
65
+ // Pastikan kita hanya menyimpan respons yang berhasil (status 200 OK)
66
+ cacheableResponse: {
67
+ statuses: [0, 200],
68
+ },
69
+ },
70
+ },
71
+ ],
72
  }),
73
  ],
74
  define: {