From 25e42e3af56b8c7700f6e5b88eec587789786668 Mon Sep 17 00:00:00 2001 From: typist Date: Wed, 29 Oct 2025 09:10:59 +0800 Subject: [PATCH] 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. --- vite.config.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/vite.config.ts b/vite.config.ts index 18ad664..fa644bb 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -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]