mirror of
https://github.com/mmahdium/portfolio.git
synced 2026-09-28 02:21:41 +03:30
feat: update caching strategy for blog routes to prevent stale HTML issues
This commit is contained in:
+14
-5
@@ -196,11 +196,20 @@ export default defineNuxtConfig({
|
|||||||
|
|
||||||
// Route rules for caching and optimization
|
// Route rules for caching and optimization
|
||||||
routeRules: {
|
routeRules: {
|
||||||
// Blog routes caching
|
// IMPORTANT:
|
||||||
'/blog': { swr: 3600 },
|
// Do NOT cache HTML pages for blog routes on Vercel/CDNs.
|
||||||
'/fa/blog': { swr: 3600 },
|
// Caching `/blog` or `/blog/<slug>` can serve stale HTML that references old `/_nuxt/*.js` chunks,
|
||||||
'/blog/**': { swr: 3600 },
|
// causing client-side navigation to intermittently 404 until a refresh loads the new HTML.
|
||||||
'/fa/blog/**': { swr: 3600 }
|
'/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 },
|
devtools: { enabled: false },
|
||||||
|
|||||||
+36
@@ -18,6 +18,42 @@
|
|||||||
"value": "public, max-age=31536000, immutable"
|
"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"
|
||||||
|
}
|
||||||
|
]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user