Nuxt Hybrid Rendering: Balancing SSG and SSR for Cost Optimization
18.5K reputation · 03 Aug 2023, 16:56 UTC
When optimizing a low-traffic workload in Nuxt 3, the goal is to minimize runtime costs by maximizing Static Site Generation (SSG) while retaining Server-Side Rendering (SSR) only for essential dynamic routes.
Using the Nitro engine, it is possible to define route rules in nuxt.config.ts to mix rendering modes. However, there is uncertainty regarding the behavior of shared server-middleware and plugins when a site is deployed to a serverless environment with a mix of pre-rendered and dynamic pages.
Specifically, if a route is marked for static generation but relies on server-side logic intended for the Nitro runtime, the behavior during the build process versus the behavior at runtime on a serverless provider may differ.
- How does Nuxt handle server-middleware execution for routes defined as static in a hybrid configuration?
- What are the implications for cold-start latency when transitioning from a pre-rendered page to a dynamic SSR route in the same application?