Merge pull request #8 from aliarghyani/visualEdit

feat: update caching strategy for blog routes to prevent stale HTML i…
This commit is contained in:
mahdiarghyani
2025-12-14 14:14:01 +03:30
committed by GitHub
2 changed files with 50 additions and 5 deletions

View File

@@ -196,11 +196,20 @@ export default defineNuxtConfig({
// Route rules for caching and optimization
routeRules: {
// Blog routes caching
'/blog': { swr: 3600 },
'/fa/blog': { swr: 3600 },
'/blog/**': { swr: 3600 },
'/fa/blog/**': { swr: 3600 }
// IMPORTANT:
// Do NOT cache HTML pages for blog routes on Vercel/CDNs.
// Caching `/blog` or `/blog/<slug>` can serve stale HTML that references old `/_nuxt/*.js` chunks,
// causing client-side navigation to intermittently 404 until a refresh loads the new HTML.
'/blog': { headers: { 'cache-control': 'no-store' } },
'/fa/blog': { headers: { 'cache-control': 'no-store' } },
'/blog/**': { headers: { 'cache-control': 'no-store' } },
'/fa/blog/**': { headers: { 'cache-control': 'no-store' } },
// These endpoints are safe to cache: they are versioned via query params/build ids.
'/blog/_payload.json': { swr: 3600 },
'/fa/blog/_payload.json': { swr: 3600 },
'/blog/rss.xml': { swr: 3600 },
'/fa/blog/rss.xml': { swr: 3600 }
},
devtools: { enabled: false },

View File

@@ -18,6 +18,42 @@
"value": "public, max-age=31536000, immutable"
}
]
},
{
"source": "/blog",
"headers": [
{
"key": "cache-control",
"value": "no-store"
}
]
},
{
"source": "/blog/(.*)",
"headers": [
{
"key": "cache-control",
"value": "no-store"
}
]
},
{
"source": "/fa/blog",
"headers": [
{
"key": "cache-control",
"value": "no-store"
}
]
},
{
"source": "/fa/blog/(.*)",
"headers": [
{
"key": "cache-control",
"value": "no-store"
}
]
}
]
}