Closed pi0 closed 3 years ago
Related https://github.com/vercel/next.js/discussions/28180. We might also set UA-based rules to enable ISR/Static based on user-agent only for mobile or search engines with a simple API. (but it obviously is not supported on all edge CDNS and need a nitro hit at least once also they cannot benefit shared-cache)
Server Rendering Strategies
Generally, we have several possible ways to render a route. In the table below, a summary is added. There are some similarities between these methods and to avoid confusing users for choosing the proper platform, we need a unified way of describing them and mentioning which nuxt version supports which and what are the trade-offs.
Strategy Configuration
We need a schema to describe route/route-groups in
nuxt.config
with their desired rendering strategy. In addition to caching, it can be useful to describe other meta like redirect rules and password protection. One important note is that, this configuration needs to be serializable to be reusable for vendor-specific purposes.Example:
Depending on the nitro platform or in-development, we can map route configuration to proper implementation.
For the context, with nuxt2, we have these options:
mode
/ssr
: Switch on/off SSR for entire projectgenerate.routes
(helping crawler and prerenderer)req.spa
(see Runtime Strategies)static
: Enable Prerender/Crawler for all routesNew
routes
can cover all but we can preserve them as shortcuts and compatibilityRuntime Strategies
Runtime strategies might be also possible but not working for all platforms if they need declarative configuration (like Vercel) and reduce optimization possibilities since we cannot easily predict what will happen for a specific route or if it is a request based rule or not. Yet we can partially support them for special cases (like this). Also we can have a way to infer config from pages.
Client-Side Behavior
Client Rendering behavior also depends on server Strategies: