milliHQ / terraform-aws-next-js

Terraform module for building and deploying Next.js apps to AWS. Supports SSR (Lambda), Static (S3) and API (Lambda) pages.
https://registry.terraform.io/modules/milliHQ/next-js/aws
Apache License 2.0
1.47k stars 151 forks source link

Add support for incremental static regeneration #11

Open ofhouse opened 4 years ago

ofhouse commented 4 years ago

See: https://nextjs.org/docs/basic-features/data-fetching/incremental-static-regeneration

dottodot commented 2 years ago

@ofhouse Do you have any update on when this might be implemented?

ofhouse commented 2 years ago

I honestly wait for AWS CloudFront to implement some features on their end that would make development on our side easier. CloudFront is laking some features (Support for stale-while-revalidate, invalidation by response headers) that are essential for ISG. My hope was that with Next.js support for Amplify they would bring such features to CloudFront, but at their current development speed I guess this will take them 5 years to implement.

With the introduction of Next.js 12 it also became clear, that relying only on AWS is not future proof, since AWS has no service in stock that could handle the new middleware function in a serverless way. So my considerations are to make the CDN part of the module interchangeable, since other CDN providers already have these features for many years.

dottodot commented 2 years ago

@ofhouse thanks for the update, surprisingly there's not many people complaining about stale-while-revalidate being missing on the aws forum so probably won't happen any time soon.

ofhouse commented 2 years ago

Yeah, it really doesn't make sense to make feature requests to AWS unless you have 500.000$ monthly AWS bill, otherwise no one ever will read your request 😅 All other developers don't have the time to wait until AWS implements a feature and move on to other providers to get their project done in time.

I guess this is how it works at this scale, so 🤷‍♂️

lcswillems commented 2 years ago

"So my considerations are to make the CDN part of the module interchangeable, since other CDN providers already have these features for many years."

@ofhouse Out of curiosity, which CDN providers have this?

ofhouse commented 2 years ago

@lcswillems To clearify, I was talking here about stale while revalidate not ISR. Cloudflare and Fastly offer native Stale while Revalidate support.

However I am optimistic that ISR can be archived through CloudFront as well with our existing infrastructure. Major roadblock was that the proxy could not check if a file in S3 exists or not, to determine if it should be served from cache or must be regenerated.

With the introduction of multiple deployments this will change and my hope is that ISR development will benefit from it (There are still some open questions especially for short regeneration times <1min).

lcswillems commented 2 years ago

Thanks for the explanations!!

JanStevens commented 2 years ago

Hi, not sure if it helps but have you taken a look at how https://github.com/serverless-nextjs/serverless-next.js does it?

I believe they set an expiration on the s3 files and use sqs queue to trigger the regeneration lamba. This way the content always stays fresh without any blocking or major timeouts.

ofhouse commented 2 years ago

@JanStevens Thanks, yes, saw that they already solved it 👍

This issue isn't about how to solve this problem anymore since I already have a plan for how to implement it. It's more about time / money now, because I need to look into ways how to make the project profitable.

So all of my work on this project is currently focused on increasing popularity and preparing paid integrations instead of working on features for now.

mohalsherif commented 2 years ago

Any update on when the paid integrations would be available. We currently would really like to have the feature, and would have no problem paying for that as well.

ofhouse commented 2 years ago

Sorry for the late answer. Unfortunately I cannot give any update on when the paid integration will become available. We started working on it, but took a bit longer to setup everything since we haven't built with the GitHub API before.

Since all of this happens in our free time, progress is painfully slow at the moment. Also working on my bachelor thesis at the moment, which also withdraws a lot of time from this project. Looks like the situation on my available time becomes better in October until then please stay patient. 😬

mohalsherif commented 2 years ago

Good luck in your thesis. We are eagerly waiting for this feature. We would be happy to support this. Maybe you can as well add the Github sponsorship option to the project so other people can show their appreciation.

mipmip commented 2 years ago

@ofhouse Are PR's welcome for feature? Do you have plans / idea's how this should be implemented?

mipmip commented 2 years ago

Our company would like to help in any way to get this ISR implemented.

ofhouse commented 2 years ago

Hey @mipmip, have some ideas how to implement it and some prerequisites are already added in the 1.0-canary release.

I am open to PRs, however my further involvement in this project is currently uncertain. I am starting a new job in November and it is not clear if I can afford more time then for support & development.

Posting more information about the future of this project in the next few weeks.