mirror of
https://github.com/mmahdium/portfolio.git
synced 2026-02-07 00:07:08 +01:00
Merge pull request #8 from aliarghyani/visualEdit
feat: update caching strategy for blog routes to prevent stale HTML i…
This commit is contained in:
@@ -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 },
|
||||
|
||||
36
vercel.json
36
vercel.json
@@ -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"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user