nextjs ISR with cloudfront

Viewed 1141

Our website, written with nextjs, currently has mix of Static pages, Server sider rendered pages and dynamic pages too. Due to increased build times, we are planning to move away from static generation and use ISR instead.

I wanted to understand how ISR should be configured on AWS Cloudfront?

We need a mechanism to update the cloudfront cache whenever certain paths are updated. As I understand Vercel takes care of this automatically. Any suggestion on how to manage this on AWS?

1 Answers

Just use Vercel

Going straight to the point: Cloudfront itself does not contain all the moving parts required for ISR. The closest you can get from that is the use of stale-while-revalidate, but it appears Cloudfront does not support it yet. Perhaps the Serverless Framework is a better candidate since they support Incremental Static Regeneration with the use of SQS and Lambda (PR link). As of now, the Serverless framework does not support On-Demand ISR since it is a brand-new feature.

Disclaimer: I work for Vercel

Related