perf: optimization for maps & network

This commit is contained in:
2026-02-26 12:39:15 -05:00
parent ba7631dc9c
commit 7b3141e5e9
5 changed files with 299 additions and 28 deletions

View File

@ -44,35 +44,48 @@ export default defineConfig(() => {
},
workbox: {
globPatterns: ['**/*.{js,css,html,ico,png,svg,woff2}'],
// ⚡ EVITA LAS PANTALLAS BLANCAS: No cachees el backend u orígenes API
navigateFallbackDenylist: [/^\/api/, /^\/rest\/v1/],
runtimeCaching: [
{
urlPattern: /^https:\/\/fonts\.googleapis\.com\/.*/i,
// ASSETS EXTERNOS E IMÁGENES SUPERBASE
urlPattern: /^https:\/\/(.*\.(png|jpg|jpeg|svg|webp|woff2|css))/,
handler: 'CacheFirst',
options: {
cacheName: 'google-fonts-cache',
expiration: {
maxEntries: 10,
maxAgeSeconds: 60 * 60 * 24 * 365, // 1 year
},
cacheableResponse: {
statuses: [0, 200],
},
cacheName: 'assets-estaticos-sibu',
expiration: { maxEntries: 100, maxAgeSeconds: 60 * 60 * 24 * 30 }, // 30 días
cacheableResponse: { statuses: [0, 200] },
},
},
{
urlPattern: /^https:\/\/fonts\.gstatic\.com\/.*/i,
handler: 'CacheFirst',
// LLAMADAS API SEMI-ESTÁTICAS (Supabase listas que no mutan tan rápido)
urlPattern: /^https:\/\/.*\.supabase\.co\/rest\/v1\/(routes|bus_stops)/,
handler: 'StaleWhileRevalidate',
options: {
cacheName: 'gstatic-fonts-cache',
expiration: {
maxEntries: 10,
maxAgeSeconds: 60 * 60 * 24 * 365, // 1 year
},
cacheableResponse: {
statuses: [0, 200],
},
cacheName: 'api-estatica-sibu',
cacheableResponse: { statuses: [0, 200] },
},
},
{
// LLAMADAS API REALTIME / DELUXE
urlPattern: /^https:\/\/.*\.supabase\.co\/rest\/v1\/(shuttles|locations|users)/,
handler: 'NetworkFirst',
options: {
cacheName: 'api-dinamica',
networkTimeoutSeconds: 5, // Vital en zonas rurales: si el 3G no responde en 5s, muestra la caché
cacheableResponse: { statuses: [0, 200] },
},
},
{
// FONT CACHE (Google)
urlPattern: /^https:\/\/fonts\.(?:googleapis|gstatic)\.com\/.*/i,
handler: 'CacheFirst',
options: {
cacheName: 'google-fonts',
expiration: { maxEntries: 10, maxAgeSeconds: 60 * 60 * 24 * 365 },
cacheableResponse: { statuses: [0, 200] },
}
}
],
},
devOptions: {