unjs / nitro

Next Generation Server Toolkit. Create web servers with everything you need and deploy them wherever you prefer.
https://nitro.unjs.io
MIT License
5.98k stars 496 forks source link

prepopulate cache during prerendering #2016

Open pi0 opened 9 months ago

pi0 commented 9 months ago

Context: https://github.com/nuxt/nuxt/issues/24828

The idea is to prerender some routes but instead of writing them directly to output/public as static HTML files, use it to repopulate cache and use bundled storage to ship it to production. This way they can be updated on demand in production (something kinda similar to Vercel's ISR)

maximilliangeorge commented 6 months ago

Not sure if it's any help, but Vercel has the concept of fallback static files: https://vercel.com/docs/build-output-api/v3/primitives#fallback-static-file

A Prerender asset may also include a static "fallback" version that is generated at build-time. The fallback file will be served by Vercel while there is not yet a cached version that was generated during runtime.

When the fallback file is served, the Serverless Function will also be invoked "out-of-band" to re-generate a new version of the asset that will be cached and served for future HTTP requests.

tux2nicolae commented 6 months ago

I'm interested in this as well