diff --git a/nuxt.config.ts b/nuxt.config.ts index 17a015b..6164a8e 100644 --- a/nuxt.config.ts +++ b/nuxt.config.ts @@ -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/` 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 }, diff --git a/vercel.json b/vercel.json index 65774bb..c0c62d4 100644 --- a/vercel.json +++ b/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" + } + ] } ] }