最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

vercel - Astro.js v5 - Is there any way to staticaly render some pages and server side render others on the same dynamic route?

programmeradmin1浏览0评论

I have 20k posts, I want to prerender 2k of them on build-time, the others should be served on demand. I am using the Vercel server adapter with the server output.

/en/guides/on-demand-rendering/#on-demand-rendering /en/guides/integrations-guide/vercel/#isr

Per the docs above, I am expected to add ISR, which I did. I also added the bypassToken and all of that, but the results I get are not what I expected.

When adding the prerender = true in a page and the getStaticPaths function, where I return my 2k pages, they are pre-rendered and are lightning fast, but the other 18k pages are not accessible and return 404. No attempt is made to fetch them. (I have a fetch logic, that returns 404 if not found). They just result in a 404 and I get a message like this

12:24:04 [WARN] [router] A getStaticPaths() route pattern was matched, but no matching static path was found for requested path /9999/this-is-slug.

Possible dynamic routes being matched: src/pages/[id]/[slug]/index.astro.

If I, however, set the prerender to false, the getStaticPaths gets ignored (it said so in the logs), and every page is server rendered, which is actually expected.

Is there a way to achieve a combination of those? Prerender 2k posts, server-render on demand the other 18k, when SSR-ing a post, it should be cached (isr), and when a post is not found, again, the 404 should be cached for that path.

与本文相关的文章

发布评论

评论列表(0)

  1. 暂无评论