Suppose I have a multi-user blog website like a Medium-clone, and when a user creates a new blog page from the web UI of the website itself, I want its HTML to be statically prerendered and served from that cache in the future under a dynamic route like /posts/[user]/[pid]
, without me having to reboot the server or run any custom manual commands to rebuild the static rendered caches.
The same issue would arrise with incremental static generation where I might want to only prerender a subset of the most actively viewed pages at build time.
When running things locally, generated prerendered files will be stored in the local filesystem under .next/server/pages
(though I couldn't find a clear example of this under https://github.com/vercel/next.js/tree/c7596be786ebe1fa5860c0f5efd7781faae0f931/examples in which pages are generated at runtime).
However, when deploying e.g. to Heroku and other PaaS systems, I would definitely need a way to specify where those newly generated HTML pages will be stored, some kind of push/fetch adapter, since Heroku's filesystem is ephemeral, and those files under .next/
that are not generated at build time by next build
can disappear randomly at any moment. Maybe it Next would just regenerate them and users wouldn't notice, but I don't want to bet on that, and at the very least there would be some performance hit. So I would likely use something like Amazon AWS S3 to store those static assets.
Is this possible or documented somewhere?
Some possibly related threads I could find:
How to use AWS with Next.js? I think this only talks about pages generated at build time, not runtime
https://vercel.com/docs/next.js/incremental-static-regeneration
https://www.reddit.com/r/nextjs/comments/mvvhym/a_complete_guide_to_incremental_static/
https://github.com/vercel/next.js/discussions/11552#discussioncomment-115595
https://dev.to/givehug/next-js-apollo-client-and-server-on-a-single-express-app-55l6
https://github.com/serverless-nextjs/serverless-next.js should do it somewhere as serverless generally implies ephemeral filesystems. Their README says that they use the Next.js serverless API https://nextjs.org/blog/next-8#serverless-nextjs but I can't find a clear documentation on how to do it without using that repository
Also, that project does claim to handle ISR on thier README.