feat: update caching strategy for blog routes to prevent stale HTML issues

This commit is contained in:
mahdiarghyani
2025-12-14 14:09:03 +03:30
parent c6b09fabc9
commit 4141593875
2 changed files with 50 additions and 5 deletions
+14 -5
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 },