fix(ui): exclude routes from service worker cache
Configure Workbox to precache only static UI assets and ignore HTML documents, preventing route responses like / and /login from being served out of cache.
This commit is contained in:
@@ -53,11 +53,15 @@ export default defineConfig({
|
|||||||
workbox: {
|
workbox: {
|
||||||
// Preserve server-side auth redirects (e.g., /login) instead of serving cached index.html.
|
// Preserve server-side auth redirects (e.g., /login) instead of serving cached index.html.
|
||||||
navigateFallback: null,
|
navigateFallback: null,
|
||||||
|
// Only precache static assets (avoid caching HTML documents / routes).
|
||||||
|
globPatterns: ["**/*.{js,css,png,jpg,jpeg,svg,webp,ico,woff,woff2,ttf,eot,json,webmanifest}"],
|
||||||
|
globIgnores: ["**/*.html"],
|
||||||
// Only cache static UI assets; never cache API traffic.
|
// Only cache static UI assets; never cache API traffic.
|
||||||
runtimeCaching: [
|
runtimeCaching: [
|
||||||
{
|
{
|
||||||
urlPattern: ({ url, request }) => {
|
urlPattern: ({ url, request }) => {
|
||||||
if (url.pathname.startsWith("/api/")) return false
|
if (url.pathname.startsWith("/api/")) return false
|
||||||
|
if (request.destination === "document") return false
|
||||||
return ["script", "style", "image", "font"].includes(request.destination)
|
return ["script", "style", "image", "font"].includes(request.destination)
|
||||||
},
|
},
|
||||||
handler: "CacheFirst",
|
handler: "CacheFirst",
|
||||||
|
|||||||
Reference in New Issue
Block a user