fix: update caching strategy for ipinfo API in Vite config

- Changed caching handler from 'NetworkFirst' to 'CacheFirst' for improved performance.
- Extended cache expiration time from 5 minutes to 1 hour to enhance data availability.
This commit is contained in:
typist
2025-10-29 09:10:59 +08:00
parent 4398b53ea7
commit 25e42e3af5

View File

@@ -32,12 +32,12 @@ export default defineConfig({
runtimeCaching: [
{
urlPattern: /^https:\/\/ipinfo\.io\/.*/i,
handler: 'NetworkFirst',
handler: 'CacheFirst', // 改为 CacheFirst优先使用缓存
options: {
cacheName: 'ipinfo-cache',
expiration: {
maxEntries: 10,
maxAgeSeconds: 60 * 5 // 5 分钟
maxAgeSeconds: 60 * 60 // 延长到 1 小时
},
cacheableResponse: {
statuses: [0, 200]