Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nuxt consumes the same amount of CPU even after prerendering (Nuxthub enabled) #124

Closed
rahulkumarsingh73690 opened this issue May 29, 2024 · 6 comments

Comments

@rahulkumarsingh73690
Copy link

Even after enabling routeRules prerender in some routes nuxt, some routes still consume the same amount of CPU.

@rahulkumarsingh73690
Copy link
Author

Is there any way to enable caching to prevent more CPU usage?

Copy link
Contributor

atinux commented May 30, 2024

Do you have the deployed website or some infos to share to help debug?

If the page is pre-rendered, it should be served from the CDN directly so not calling the Nuxt server (worker).

@rahulkumarsingh73690
Copy link
Author

rahulkumarsingh73690 commented May 30, 2024

I don't have stats but pre-rendered still counts as a worker request and CPU usage. I have a traffic site where I am facing this issue.

I will try get data from small project

And one more thing

'/blog/**': { prerender: true },

Does nothing only

'/blog/': { prerender: true },

Works

@rahulkumarsingh73690
Copy link
Author

rahulkumarsingh73690 commented May 30, 2024

Please check full discussion on discord with @manniL - https://discord.com/channels/473401852243869706/1244656036002926645

Copy link
Contributor

atinux commented May 30, 2024

So, Nitro cannot follow the link as we did not configure the crawlLinks option but we should not in the hybrid mode

One solution is to use the prerenderRoutes()[https://nuxt.com/docs/api/utils/prerender-routes) util in your blog.vue page to list all the other blog post pages.

Example:

<script setup>
const { data: posts } = await useFetch('/api/posts')

prerenderRoutes(posts.value.map(post => `/blog/${post.slug}`))
</script>

@rahulkumarsingh73690
Copy link
Author

nitrojs/nitro#2498

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants