Why shouldn't I prerender all my sites pages?

hey y’all! So we have pre-rendering working great for some of our most visited/data-intesive pages, and it got me to thinking is there any reason not to pre-render every page of the app? I noticed that with pre-rendering, you have to specify the route in routes.js so you can force private caching, set the max age, etc. which means you can’t leave the routing to nextRoutes and the next file system routing alone. Was just wondering what patterns you’ve seen or suggest in this scenario.

The ideal pattern in our opinion is one where you have to do the least work to think about what to prerender. For example, we’re working on a feature that will automatically pick which pages to prerender based on traffic logs we already have. It’s one of the ways we are planning to tie intelligence and data we have about the site into its optimization. So ideally you are explicit about a few pages and then tell our system, “just prerender the top 1000 based on traffic”.In the meantime, the answer is “it depends” on your case but the following are considerations to think about when deciding how many pages to prerender:

  • How many pages does your site have? There are defined limits on the number of pages that can be pre-rendered as declared in our documentation: https://developer.moovweb.com/guides/static_prerendering#section_concurrency_and_limits
  • Can your backend support all those requests from prerendering in such a short period of time (i.e. will prerendering flood your origin with too many requests)? We’ve encountered origin servers that can handle that influx of traffic at all once (it actually kind of looks like an attack). Bringing down the concurrency level as described in https://developer.moovweb.com/guides/static_prerendering#section_concurrency_and_limits can help.
  • Are all those pages worth prerendering? As an extreme example consider a page that is visited once a week but you’re doing deploys every day. Keep in mind prerendering does incur serverless compute time, i.e. cost. So is it really worth rendering a page seven times during a week if it will only be accessed once? On a larger site this is a more complex question to answer which is why we believe automation that uses data about site traffic is the best way to balance these tradeoffs.

Super interesting. Where do you grab the site data from? Is that a config or are you looking at Google analytics?

@molebox , Hi Richard! Great question. Since we’re also the CDN we already have the traffic data. This is also how we’re able to report on cache hit rates in the cache metrics screen.

1 Like